I think it's because you are using .some()
which only returns true
or false
. Use .find()
instead in both cases (role
and member
).
Edit:
Try this:
client.on('messageReactionAdd', (reaction, user) => {
if(user.bot) return;
var roleName = reaction.emoji.name;
var role = reaction.message.guild.roles.cache.find(role => role.name.toLowerCase() === roleName.toLowerCase());
reaction.message.guild.members.fetch(user).then(m => m.roles.add(role).then(member => {
console.log('Added ' + member.user.username + ' to a role.');
}))
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…