import { Command } from 'discord-akairo'; import { Message } from 'discord.js'; import Axios from 'axios'; export default class DateFactFun extends Command { public constructor() { super('datefact', { aliases: ['datefact'], category: 'fun', description: { content: 'Grabs a fact about a specified date.', usage: '[numeric day] [numeric month]', examples: [ '8 4' ] }, ratelimit: 3, args: [ { id: 'day', type: 'integer', prompt: { start: 'What day would you like to get facts for? (Numeric value)', retry: 'That is not a valid day, please try again.', retries: 3 }, default: 'random', }, { id: 'month', type: 'integer', prompt: { start: 'What month would you like to get facts for? (Numeric value)', retry: 'That is not a valid month, please try again.', retries: 3 }, default: 'random', } ] }); } public async exec(msg: Message, { day, month }): Promise { const uri = `http://numbersapi.com/${month === 'random' || day === 'random' ? 'random' : `${month}/${day}/date`}`; const fact = await Axios.get(uri).catch(err => { console.error(err); return msg.reply('Woops, there was an error regarding the (http://numbersapi.com) API.'); }); //@ts-ignore return msg.reply(fact.data); } }