import { Command } from 'discord-akairo'; import { Message } from 'discord.js'; import Axios from 'axios'; export default class YearFactFun extends Command { public constructor() { super('yearfact', { aliases: ['yearfact'], category: 'fun', description: { content: 'Grabs a fact about a specified year.', usage: '[numeric year]', examples: [ '1995' ] }, ratelimit: 3, args: [ { id: 'year', type: 'integer', prompt: { start: 'What year would you like to get facts for? (Numeric value)', retry: 'That is not a valid year, please try again.', retries: 3 }, default: 'random', } ] }); } public async exec(msg: Message, { year }): Promise { const fact = await Axios.get(`http://numbersapi.com/${year}/year`).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); } }