您可以锁定频道,但是如果有人再次执行该命令,则如何发送一条消息通知该频道已被锁定。
if (command === "lock") {
await message.channel.overwritePermissions(message.guild.defaultRole, {
SEND_MESSAGES: false
});
return message.channel.send(`:lock: The channel is now locked..\nUse \`k!unlock\` to end lockdown.. `);
}
答案 0 :(得分:0)
您可以使用TextChannel.permissionOverwrites
(每次覆写的集合):
let {id} = message.guild.defaultRole, // get the ID of defaultRole
ow = message.channel.permissionOverwrites.get(id); // get the permissionOverwrites fro that role
// If the overwrites exist and SEND_MESSAGES is set to false, then it's already locked
if (ow && ow.SEND_MESSAGES === false) message.channel.send("The channel is already locked.");
else { // otherwise, lock it
await message.channel.overwritePermissions(message.guild.defaultRole, { SEND_MESSAGES: false }, );
return message.channel.send(`:lock: The channel is now locked..\nUse \`k!unlock\` to end lockdown.. `);
}