Message Reactions

I’m making a JavaScript Discord bot, how do I do something when someone reacts to a certain emoji on a message? Please may I have some code?

This is a nice tutorial on how to make a basic reaction collector and await reactions

Tell us if you have a problem with it

I looked at that. How would I make it so the bot doesn’t trigger the code when it reacts?

Can you please explain what you’re wanting more? From what I understand, you want an event to be fired when someone reacts, but don’t want it to execute code.

no he wants the bot to react with all the reactions you can use to trigger but the but wouuld end up firing the code when it does

Hey there,
You may know Node.js events.
So, here’s what we are gonna do: the event messageReactionAdd triggers whenever someone reacts to a message. We’l; use that event to get the data required.

client.on('messageReactionAdd', (reaction, user) => {
// wallah!
// you can now access the property and methods of reaction as well as the user reacted on the message.

Cheers, for further queries feel free to mention me!

In that case, you would need to have the code block out bot accounts. Here’s an example:

client.on('messageReactionAdd', function(reaction, user) {
    if (! {
        //The following code will only run if the user is not a bot, therefore filering out the initial bot reactions.

Hope this answered your question!

How do I check for a specific emoji?

Basically, I’m making a help menu on a channel. So if a certain reaction is clicked, a channel is created. If another reaction is clicked, a message will send.

I do something like this for doing something for specific emojis:

	const { message, emoji } = messageReaction;
if( === "the emoji here") {
// code to run when that emoji is reacted to on a message

How does it know what message to look for?

If you want it to be a specific message do this:

client.on('messageReactionAdd', (messageReaction, user) => {
if(  return;
const { message, emoji } = messageReaction;

if( === "the emoji here") {
if( === "message id here") {
// code to run when that emoji is reacted on specified message
1 Like

Thank you so much!!!