Created
February 6, 2021 15:05
-
-
Save thomasstr/9240fc2bbce77f2db24948437f648a3a to your computer and use it in GitHub Desktop.
Await for reaction Discord JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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