5 回答
TA贡献1796条经验 获得超10个赞
你应该这样做,你的代码看起来很长:
if (!message.member.roles.cache.some(role => role.name === 'Moderator')) return;
message.channel.updateOverwrite(message.channel.guild.roles.everyone, { SEND_MESSAGES: false })
message.channel.send(`Successfully locked **${message.channel.name}**`)
从你的角色中替换message.channel.guild.roles.everyone。
TA贡献1860条经验 获得超8个赞
这不是你如何更新权限而不是这个:
channel.overwritePermissions(
Role, {
'SEND_MESSAGES': false
},
'Competitive has Ended'
)
用这个:
channel.overwritePermissions([
{
id: roleId,
deny: ['SEND_MESSAGES']
}]
,'Competitive has Ended'
)
TA贡献1804条经验 获得超7个赞
下面这段代码可能对你有帮助
channel.overwritePermissions(
[
{
id: roleId,
deny: [
'SEND_MESSAGES'
]
}
]
, 'Mark my question'
)```
TA贡献1744条经验 获得超4个赞
你也应该使用updateOverwrite而不是overwritePermissions。
例子:
module.exports = {
name: "lock",
description: "Lock",
run(client, message, args) {
const targetChannel = message.mentions.channels.first() || message.channel;
// Guild ID is the same as the everyone role ID
const everyoneID = message.guild.id;
targetChannel.updateOverwrite(everyoneID, {
SEND_MESSAGES: false,
});
targetChannel.send(`**${targetChannel.name}** has been locked :lock:`);
}
}
也不需要它是异步函数,因为您没有在代码中使用 await 。
TA贡献1784条经验 获得超2个赞
您只需调用以下行即可删除当前频道的发送权限:
const Role = guild.roles.find("name", "Verified ");
message.channel.overwritePermissions(role,{ 'SEND_MESSAGES': false })
如果你想制作解锁频道命令,只需在命令下添加:
const Role = guild.roles.find("name", "Verified ");
message.channel.overwritePermissions(role,{ 'SEND_MESSAGES': true})
添加回答
举报