Thunder0795
Thunder0795

Reputation: 5

How to check the role of a reacting member discord.js

I'm fairly new to discord.js and have recently ran into a problem with a section of my code.

if (reaction.message.member.roles.cache.some(role => role.name == "Goof Archivist 📚")) {

This section is supposed to check if a reacting member has the role "Goof Archivist 📚". But instead checks the role of the person that sent the message that is being reacted to. if that makes sense. any help would be appreciated.

My code

Upvotes: 0

Views: 135

Answers (1)

Lioness100
Lioness100

Reputation: 8412

You can use the second parameter of the messageReactionAdd event, the User that reacted, and the Guild.member() method.

Guild.member() can convert a global user object to a guildmember object in which you can see the roles of. To learn the difference between the two, check out What is the difference between a User and a GuildMember in discord.js?.

if (
 reaction.message.guild
  .member(user)
  .roles.cache.some((role) => role.name == 'Goof Archivist 📚')
)

Upvotes: 2

Related Questions