This will make removing reactions easier, when a user reacts.
a. Going back:
This will handle going back a page.
if (reaction.emoji.name==='⬅') { // remove the back reaction if possibleawaitremoveReaction(m,msg,'⬅'); // check if the page can go back oneif (page!=min) { // change the pagepage=page-1;awaitm.edit({embed:pages[page] });} // restart the listener awaitReactions(msg,m,options,filter);}
I'll keep comments inside the code to keep it cleaner and easier to understand, but this code here will remove the reaction (if the bot has permission), check if it can go back, go back if it can, then start listening again.
b. Going forward:
This will, ironically, handle going forward a page.
That handles, well, that. Same thing happens here, just the code is changed a little.
c. Handling the delete:
Incase anyone wants to delete the help command, we can add a trash reaction to do that.
This will delete the embed fully, and stop listening.
d. Handling mis-reactions:
Just in case something happens, this code is here to restart the listener if something goes wrong:
And that's it! Your reaction help menu is done now, and all you have to do is do some proper pages, and give it a test run!
else if (reaction.emoji.name === '➡') {
// remove the back reaction if possible
await removeReaction(m, msg, '➡');
// check if the page can go forward one
if (page != max) {
// change the page
page = page + 1;
await m.edit({ embed: pages[page] });
}
// restart the listener
awaitReactions(msg, m, options, filter);
}
else if (reaction.emoji.name === '🗑') {
// trash the message instantly, returning so the listener fully stops
return await m.delete();
}
else {
awaitReactions(msg, m, options, filter);
};