如何查看频道权限?

How to check channel permissions?

您可以锁定频道,但是如果有人再次执行该命令如何发回该频道已被锁定的消息。

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.. `);
}

您可以使用 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.. `);
}