【发布时间】:2021-02-04 16:00:41
【问题描述】:
所以,在制作我的 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)
我怎样才能解决这个问题?在此先感谢:)
【问题讨论】:
-
如果您使用的是 12.4,
find('name', 'everyone')已过时。见this post -
哦,哇,谢谢,这似乎解决了问题。
标签: javascript discord.js