diff options
Diffstat (limited to 'server/src/commands/fun/NumberFact.ts')
| -rw-r--r-- | server/src/commands/fun/NumberFact.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/server/src/commands/fun/NumberFact.ts b/server/src/commands/fun/NumberFact.ts new file mode 100644 index 0000000..2739218 --- /dev/null +++ b/server/src/commands/fun/NumberFact.ts @@ -0,0 +1,41 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import Axios from 'axios'; + +export default class NumberFactFun extends Command { + public constructor() { + super('numberfact', { + aliases: ['numberfact', 'number-fact', 'numfact', 'num-fact'], + category: 'fun', + description: { + content: 'Grabs a facts about a specified number.', + usage: '[number]', + examples: [ + '8' + ] + }, + ratelimit: 3, + args: [ + { + id: 'number', + type: 'integer', + prompt: { + start: 'What number would you like to get facts for? (Numeric value)', + retry: 'That is not a valid number, please try again.', + retries: 3 + }, + default: 'random', + } + ] + }); + } + + public async exec(msg: Message, { number }): Promise<Message> { + const fact = await Axios.get(`http://numbersapi.com/${number}`).catch(err => { + console.error(err); + return msg.reply('Woops, there was an error with the (http://numbersapi.com) API.'); + }); + //@ts-ignore + return msg.reply(fact.data); + } +}
\ No newline at end of file |