Reputation: 53
I'm making a bot with an automatic role system using reactions.
Here's a shortened version of my current relevant code:
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.
});
I just want to know how to add a role to a user with the user
object.
I have tried reaction.message.channel.guild.member(user).addRole(role);
, but I think that's deprecated for v12.2.0, as it just generates an error ...).addRole() is not a function
.
Any help is appreciated!
Upvotes: 3
Views: 4850
Reputation: 5174
Since discord.js v12 addRole()
has been replaced with roles.add()
so it is indeed not a function.
reaction.message.guild.member(user).roles.add(role);
Upvotes: 4