js v12.2.0"/>
Discord.js v12.2.0
我正在使用反应使机器人具有自动角色系统。这是我当前相关代码的简化版本:
client.on("messageReactionAdd", (reaction, user) => {
if(!user || user.bot || !reaction.message.channel.guild) {
return;
}
const msg = reaction.message;
const role = msg.channel.guild.roles.cache.find(role => role.name == "Verified");
// I would like to add the role to the user here.
});
我只想知道如何使用user
对象向用户添加角色。我已经尝试过reaction.message.channel.guild.member(user).addRole(role);
,但我认为v12.2.0不推荐使用,因为它只会产生错误...).addRole() is not a function
。任何帮助表示赞赏!
由于discord.js v12 addRole()
被替换为roles.add()
,所以它实际上不是功能。
reaction.message.guild.member(user).roles.add(role);
更多推荐
Discord.js v12.2.0
发布评论