Add role to user

My verify command is not working heres the code

if (command === “verify” || command === “ver”) {
message.delete();
if (message.channel.id === “760281312317014046”) {
const mainrole = message.member.roles.some(
role => role.name === “Member”
);
const member = message.member;

  member.roles.add(mainrole.id);
}

}
});

You’re using message.member.roles.some which is invalid with discord.js v12 - you need to update to message.member.roles.cache.some.

Also, if you want to add a role you must use a RoleResolvable, in your code you’re trying to add something that will either be true or false - not a RoleResolvable.

You should instead be using message.member.roles.cache.find(role => role.name === "Member") which will return a RoleResolvable.



2 Likes

Ill try thx