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})
添加回答
舉報