如何覆盖特殊频道的权限

时间:2020-09-29 09:18:46

标签: node.js discord.js

我需要一段时间覆盖权限

例如:

message.channel.send('you don\'t has permission to send message');
// (overwrite send message permission to false for x role)
// 5min time out later
// (overwrite send message permission to true for X role)

人员:!全部屏蔽

另一个人:您无权发送消息

5分钟后

另一个人:正常书写

我该怎么做。

1 个答案:

答案 0 :(得分:1)

您可以使用Channel.updatePermissions()setTimeout函数。

// `updateOverwrites()` accepts a user or role id
// I'm using `message.guild.id` because, fun fact,
// the @everyone role shares the same id as the guild its in
function lockChannel(bool) {
  message.channel.updateOverwrites(message.guild.id, 
    {
       SEND_MESSAGES: !bool, // update their send messages permission
    },
  );
}

// lock channel
lockChannel(true);

// wait five minutes and unlock it
setTimeout(() => lockChannel(false), 300000);