PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 20, 2022

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

 October 20, 2022     discord.js, javascript, node.js     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

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

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing