Created
February 12, 2021 18:16
-
-
Save thomasstr/625bd408617e0f8cf1a28f291e7a86fc to your computer and use it in GitHub Desktop.
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 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'); |
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"); | |
// 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