Basic Reaction Logic (1/2)
The start of the logic for handling reactions.
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.
Last updated
Was this helpful?