Skip to content Skip to sidebar Skip to footer

Discord Js Check Reaction User Role

I am trying to close a ticket by reacting to a button. But reaction must be given by 'support' role. I couldnt do it. reaction.message.member.roles.has is not helping me at this po

Solution 1:

All of this wrapped inside the messageReactionAdd event

// Replace "message_id" with the proper message id// Checks if it's the correct messageif (reaction.message.id == "message_id") {

     // Check if author of ticket message is from the same user who reactedif (reaction.message.author == user) {

          // Check correct emojiif (reaction.emoji.name == "🔒") {
               // Code to close ticket
          }

     }

}

EDIT: Again, this would be wrapped inside the messageReactionAdd event:

// Try to get the ticket message// If there's none then the user was never opened a ticket so we simply return the codeconst ticketMessage = client.tickets.get(user);
if (!ticketMessage) return;

// Checks if it's the correct messageif (reaction.message.id == ticketMessage.id) {

     // Check correct emojiif (reaction.emoji.name == "🔒") {
         // Code to close ticket
     }

}

I removed the code that check for the reaction message author because getting ticketMessage already handles that. Do note that this means you can make sure a user can only open one ticket.

Post a Comment for "Discord Js Check Reaction User Role"