[Solved] How do you give a user a role by role ID in Discord.JS V13 (latest)


You can do this something like same thing with getting member.id.

const member = message.mentions.members.first() || message.guild.members.cache.get(args[0])

You can create the code similar to this.

const role = message.mentions.roles.first() || message.guild.roles.cache.get(args[0])

Now you can adjust your code file:

const member = message.mentions.members.first() || message.guild.members.cache.get(args[0])
const role = message.mentions.roles.first() || message.guild.roles.cache.get(args[1])

member.roles.add(role) //To add the mentioned or given role id the the member.

You can see the image below, the format is args[0] for member and args[1] is for role. Try to experiment your code for this time!

                                       Example add role

solved How do you give a user a role by role ID in Discord.JS V13 (latest)