Skip to content

Instantly share code, notes, and snippets.

@thomasstr
Created February 12, 2021 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasstr/625bd408617e0f8cf1a28f291e7a86fc to your computer and use it in GitHub Desktop.
Save thomasstr/625bd408617e0f8cf1a28f291e7a86fc to your computer and use it in GitHub Desktop.
const Discord = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
console.log('Ready!');
});
client.on('message', message => {
if (message.content === '!react-await') {
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: 60000, 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.');
});
}
});
client.login('TOKEN_HERE');
const Command = require("../base/Command.js");
// const yahooStockPrices = require("yahoo-stock-prices");
// const { ChartJSNodeCanvas } = require('chartjs-node-canvas');
class Realtime extends Command
{
constructor (client)
{
super(client,
{
name: "realtime",
description: "Gets realtime stock values",
category: "System",
usage: "realtime ticker",
guildOnly: false,
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: 60000, 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