Skip to content

Instantly share code, notes, and snippets.

@thomasstr
Created February 6, 2021 15:05
Show Gist options
  • Save thomasstr/9240fc2bbce77f2db24948437f648a3a to your computer and use it in GitHub Desktop.
Save thomasstr/9240fc2bbce77f2db24948437f648a3a to your computer and use it in GitHub Desktop.
Await for reaction Discord JS
const Command = require("../base/Command.js");
class Realtime extends Command
{
constructor (client)
{
super(client,
{
name: "realtime",
description: "Gets realtime stock values",
category: "System",
usage: "realtime ticker",
permLevel: "Bot Owner",
aliases: []
});
}
async run (message, args, level)
{ // eslint-disable-line no-unused-vars
message.react('๐Ÿ‘').then(() => message.react('๐Ÿ‘Ž'));
const filter = (reaction, user) => {
return ['๐Ÿ‘', '๐Ÿ‘Ž'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 5000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '๐Ÿ‘') {
message.reply('you reacted with a thumbs up.');
} else {
message.reply('you reacted with a thumbs down.');
}
})
.catch(collected => {
console.log(`After a minute, only ${collected.size} out of 4 reacted.`);
message.reply('you didn\'t react with neither a thumbs up, nor a thumbs down.');
});
}
}
module.exports = Realtime;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment