更改@everyone权限Discord JS时出错



因此,在制作DiscordJS机器人程序时,我遇到了另一个问题。我正在尝试创建一个锁定通道功能,通过更改@everyone的权限来防止用户在该通道中发送消息。当你发出命令时,你会提到通道,就像这个!lockchannel #general。但这会产生一个错误:chan.updateOverwrite is not a function。代码如下:

//...
// msg is the message object
if (msg.mentions.channels.first()) {
const chan = msg.mentions.channels.first()
const role = chan.guild.roles.find('name', 'everyone');
chan.updateOverwrite(role, { SEND_MESSAGES: false }).catch((error) => console.log(error))
} else {
msg.reply("You didn't mention a channel")
}
//...

我使用的是最新版本的Discord JS(12.4.0(
我该如何修复?提前感谢:(

//...
// msg is the message object
if (msg.mentions.channels.first()) {
const chan = msg.mentions.channels.first()
chan.updateOverwrite(msg.guild.id, { SEND_MESSAGES: false }).catch((error) => console.log(error))
} else {
msg.reply("You didn't mention a channel")
}
//...

要更新每个人的排列,只需使用公会的id

您只需要message.channel.updateOverwrite(message.channel.guild.roles.everyone, { SEND_MESSAGES: false })将message.channel从已定义的通道中替换出来,然后吊杆就完成了!

最新更新