diff options
Diffstat (limited to 'src/commands/fun/numberfact.ts')
| -rw-r--r-- | src/commands/fun/numberfact.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/commands/fun/numberfact.ts b/src/commands/fun/numberfact.ts new file mode 100644 index 0000000..9e7b698 --- /dev/null +++ b/src/commands/fun/numberfact.ts @@ -0,0 +1,47 @@ +import { Command, CommandoMessage } from 'discord.js-commando'; +import axios from 'axios' +import emoji from 'emoji-random' + +module.exports = class NumberFactFun extends Command { + constructor(client) { + super(client, { + name: 'numberfact', + aliases: [ + 'number-fact', + 'numberfacts', + 'number-facts', + 'numfact', + 'num-fact', + 'numfacts', + 'num-facts' + ], + group: 'fun', + memberName: 'numberfact', + description: 'Grabs facts about a specified number.', + args: [ + { + key: 'nNum', + prompt: 'What number would you like to get facts for?', + type: 'integer', + max: 31, + min: 1, + default: 'random' + } + ], + examples: ['uwu!numberfact', 'uwu!numberfact 12'], + throttling: { + usages: 5, + duration: 30 + }, + userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'] + }); + } + async run(msg: CommandoMessage, { nNum }) { + const fact = await axios.get(`http://numbersapi.com/${nNum}`).catch(err => { + console.log(err) + msg.reply('Woops, here was an error with the (http://numbersapi.com) API. ' + emoji.random()) + }) + msg.reply(fact.data) + } +};
\ No newline at end of file |