【发布时间】:2021-04-21 09:01:57
【问题描述】:
所以,我有一个命令可以阻止@everyone 角色向频道发送消息。我想让用户可以运行该命令并连同它一起提及一个特定的角色,然后该角色的成员将被阻止发送消息。 到目前为止,这是我的代码,它只锁定了所有人的角色:
if (!message.guild.me.hasPermission(`MANAGE_CHANNELS`)) return message.reply('I lack the required permissions to run this command. (Required Permissions: ``MANAGE_CHANNELS``)');
if(message.member.hasPermission("MANAGE_CHANNELS")){
const channel = message.channel
const Discord = require("discord.js")
let replyMessage = message.reply("Are you sure you want to continue this command, it will remove send permissions from the everyone role. Type ``yes`` to continue.")
let filter = msg => msg.author.id == message.author.id && msg.content.toLowerCase() == 'yes';
message.channel.awaitMessages(filter, {max: 1, time: 20000}).then(collected => {
message.reply('Confirmed!');
message.channel.updateOverwrite(message.guild.everyone, {
SEND_MESSAGES: false
})
.then(channel => channel.send("Channel Locked"))
.catch(console.error);
});
我在检查角色提及方面找不到太多信息,但我有这个,想知道您是否可以更改 message.mentions.**members**.first() 并将其替换为 message.mentions.**roles**.first():
let member = message.mentions.members.first() || message.guild.members.cache.get(args[0])
并且想知道是否有人可以帮助我。 谢谢。
【问题讨论】:
标签: node.js discord discord.js