【发布时间】:2021-05-22 08:43:02
【问题描述】:
我想为我的机器人提供使用命令分配角色的功能
例如,+mod @user 将赋予 @user Mod 角色。
代码在我的main.js:
if(command == 'mod'){
client.commands.get('mod').execute(message, args);
}
我的mod.js 文件中的代码:
module.exports = {
name: 'mod',
description: "This command gives member the Mod role",
execute(message, args){
const member = message.mentions.users.first();
member.roles.add('role ID xxxx');
}
}
我收到一条错误消息,提示该成员为空。我做错了吗?
【问题讨论】:
标签: javascript node.js discord.js