我还没有设法使漫游器向用户添加角色。该机器人做出反应后就可以正常工作。
var roleName = reaction.emoji.name;
var role = reaction.message.guild.roles.find(role => role.name.toLowerCase() === roleName.toLowerCase());
var member = reaction.message.guild.members.find(member => member.id === user.id);
if (member.roles.has(role.id)) {
member.removeRole(role.id).then(member => {
console.log("Removed " + member.user.username + " from the " + role.name + " role.");
}).catch(err => console.error);
}
else {
member.addRole(role.id).then(member => {
console.log("Added " + member.user.username + " to the " + role.name + " role.");
}).catch(err => console.error);
}