Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add user to role with newest discord.js

i'm using newest discord.js in node.js and i'm trying to add user to role, but it seems bot.addUserToRole() was removed.

How can I do it when I know only rank name, not it's ID?

like image 322
GuyWhoDoThings Avatar asked Apr 01 '18 15:04

GuyWhoDoThings


2 Answers

Here's what worked for me, hope this helps!

var role= member.guild.roles.cache.find(role => role.name === "role name");
member.roles.add(role);

Here is the official documentation on it.

like image 58
Y. Georgiev Avatar answered Oct 09 '22 19:10

Y. Georgiev


You can do this with:

var role = message.guild.roles.find(role => role.name === "MyRole");
message.member.addRole(role);
like image 39
André Avatar answered Oct 09 '22 19:10

André