summaryrefslogtreecommitdiff
path: root/src/commands/fun/dayfact.ts
blob: f30b828a97e4d19227486d29ee37cb4432e48ec7 (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
42
43
import { Command, CommandoMessage } from 'discord.js-commando';
import axios from 'axios'
import emoji from 'emoji-random'

module.exports = class DayFactFun extends Command {
    constructor(client) {
        super(client, {
            name: 'dayfact',
            aliases: [
                'day-fact',
                'dayfacts',
                'day-facts'
            ],
            group: 'fun',
            memberName: 'dayfact',
            description: 'Grabs facts about a specified day.',
            args: [
                {
                    key: 'day',
                    prompt: 'What day would you like to get facts for?',
                    type: 'integer',
                    max: 31,
                    min: 1,
                    default: 'random'
                }
            ],
            examples: ['uwu!dayfact', 'uwu!dayfact 12'],
            throttling: {
                usages: 5,
                duration: 30
            },
            userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
            clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY']
        });
    }
    async run(msg: CommandoMessage, { day }) {
        const fact = await axios.get(`http://numbersapi.com/${day}/date`).catch(err => {
            console.log(err)
            msg.reply('Woops, here was an error with the (http://numbersapi.com) API. ' + emoji.random())
        })
        msg.reply(fact.data)
    }
};