如何覆盖特定用户对discord的权限
我需要在运行像“!overwide”这样的命令时进行设置,这样只有指定的人才能看到频道,而不是整个角色。这是我到目前为止的代码。我试过许多不同的写作方法如何覆盖特定用户对discord的权限,discord,discord.js,Discord,Discord.js,我需要在运行像“!overwide”这样的命令时进行设置,这样只有指定的人才能看到频道,而不是整个角色。这是我到目前为止的代码。我试过许多不同的写作方法 const { Message } = require("discord.js") module.exports = { name:'afellow', description: "give a specific person", execute(message, args, Discord) { l
const { Message } = require("discord.js")
module.exports = { name:'afellow', description: "give a specific person",
execute(message, args, Discord) {
let memberToFind = message.mentions.members.first();
let channels = [
'810951137287995495',
'810952727529127946',
]
if (!channels) return message.channel.send('N/A')
if (!memberToFind) return message.channel.send('Mention a user!')
if(message.member.roles.cache.find(r => r.name === "FellowshipOwner")) {
message.channel.updateOverwrite(memberToFind, { VIEW_CHANNEL: true, SEND_MESSAGES: true }).catch();
} else {
message.channel.send('Sorry, You must be a fellowship owner to use this command.')
}
}
}
由于您已经拥有您提到的成员的成员对象,您可以通过提及该对象的变量,简单地在通道中更新其覆盖 附言:我已经在你当前的工作中添加了更多的代码,并修复了一些常见的错误 最终代码
谢谢我想我还得加点别的。因为我希望这只在几个频道,我做了下面的代码,但它似乎不工作。你能再帮我一次吗?(我编辑我的帖子是为了向你展示)代码似乎适用于所有频道,而不是我指定的频道。
const { Message } = require("discord.js")
module.exports = { name:'fellow', description: "give a specific person", execute(message, args, Discord) {
let memberToFind = message.mentions.members.first();
/*
if (!memberToFind) return message.reply('Mention a user!')
*/
if(message.member.roles.cache.find(r => r.name === "FellowshipOwner")) {
message.channel.updateOverwrite(memberToFind, { VIEW_CHANNEL: true, SEND_MESSAGES: true });
} else {
message.channel.send('Sorry, You must be a fellowship owner to use this command.')
}
}