我不确定如何在Discord.js中创建将提到的用户添加到角色的命令。
例如:?addrole @JustProGaming#1785 @Owner
答案 0 :(得分:0)
您可以这样:每次调用addrole
命令时,将每个提到的角色分配给每个提到的成员。这种结构非常好,因为无论参数的顺序如何,它都可以工作。
// 'message' is the message that triggered the command
if (command == 'addrole') {
let members = message.mentions.members,
roles = message.mentions.roles;
if (!members.size) return message.reply("You didn't mention any member!");
if (!roles.size) return message.reply("You didn't mention any role!");
members.forEach(member => member.addRoles(roles, `Command issued by ${message.author.tag}`));
}