discord.js add role to user 1

discord.js add role to user

let role = message.guild.roles.cache.find(r => r.id === "Role ID");

// The member you want to add the role to
let member = message.mentions.members.first();

// Add role to the member
member.roles.add(role);

// Or add it to yourself
message.author.roles.add(role);

Here is what the above code is Doing:
1. We’re defining the role we want to add to the member.
2. We’re defining the member we want to add the role to.
3. We’re adding the role to the member.
4. We’re adding the role to the author of the message.

Similar Posts