Discord.js Reaction Help Guide
  • Welcome
  • Before you start..
  • Stable
    • Getting Started
    • Command
    • Basic Reaction Logic (1/2)
    • Finishing Reaction Logic (2/2)
    • And we're done!
Powered by GitBook
On this page

Was this helpful?

  1. Stable

Basic Reaction Logic (1/2)

The start of the logic for handling reactions.

PreviousCommandNextFinishing Reaction Logic (2/2)

Last updated 6 years ago

Was this helpful?

Heading back up to the // the reaction logic will be here comment, lets replace it with a bare-bones function:

(^)

const awaitReactions = async (msg, m, options, filter) => {
    // simplify the use of these options, using destructing^
    const { min, max, page, limit } = options;
    
    m.awaitReactions(filter, { max: 1, time: limit, errors: ['time'] })
    .then(async (collected) => {
        // logic
    }).catch(() => {});
}

Heading in to the function, where // logic sits, lets pull the reaction from what we collected:

const reaction = collected.first();

Now we have our reaction, and what we need ready, we can add the scaffolding for reactions, and handle them accordingly:

// add this below where we define reaction, but inside the '.then'

if (reaction.emoji.name === '⬅') {
    // a.       
}
else if (reaction.emoji.name === '➡') {
    // b.
}
else if (reaction.emoji.name === '🗑') {
    // c.
}
else {
    // d.
}

Now we can move on.

see more about destructing