Thursday, October 20, 2022

[FIXED] What is the best way of figuring out when someone reacts to a message (discord.js)

Issue

I am trying to figure out if someone reacted to a message sent by the bot. I have tried reactions.awaitReactions() but you must select a time and I just want to respond after they react. Is there any way of doing this? I have tried a few different ways of getting this but none have worked in way I wanted.

enter image description here


Solution

The way I got this to work is by adding the below. This is the best way I could find because all other ways you must select a time and that just makes this all pointless.

 client.on('messageReactionAdd', async (reaction, user) => {
              console.log(user.id == message.author.id)
            if(user.bot) return 
            if(!user.id == message.author.id) return
            console.log(reaction.emoji)
            if(reaction.emoji.name == '👍'){
                message.reply("Good")
            
            }else if(reaction.emoji.name == '👎'){
                message.reply("Bad")
            }
    
        })


Answered By - Thebeston123
Answer Checked By - Mary Flores (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.