summaryrefslogtreecommitdiff
path: root/server/src/commands/fun/DayFact.ts
blob: df5d3b7a5cee156d1bb34f4b0ac2be6f7830c700 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
import Axios from 'axios';

export default class DayFactFun extends Command {
    public constructor() {
        super('dayfact', {
            aliases: ['dayfact'],
            category: 'fun',
            description: {
                content: 'Grabs a fact about a specified day.',
                usage: '[numeric day]',
                examples: [
                    '8'
                ]
            },
            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',
                }
            ]
        });
    }
    
    public async exec(msg: Message, { day }): Promise<Message> {
        const fact = await Axios.get(`http://numbersapi.com/${day}/date`).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);
    }
}