Skip to content Skip to sidebar Skip to footer

How To Check If A Specific User Has A Role? Discord Js

I know how to check if the message sender has a role: if(message.member.roles.has(role.id)) { console.log(`Yay, the author of the message has the role!`); } else { console.log(

Solution 1:

message.member.roles is considered a GuildMemberRoleManager (Documentation), to access the collection of roles you must access the property .cache which is a collection. This collection then has the .has(...) method function. (Documentation)

Thus, you instead want to access message.member.roles.cache.has(...)

Post a Comment for "How To Check If A Specific User Has A Role? Discord Js"