summaryrefslogtreecommitdiff
path: root/server/src/commands/fun/Advice.ts
blob: 17035c0547e4169f1e26b546bd4bff8455688c26 (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
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
import Axios from 'axios';

export default class AdviceFun extends Command {
    public constructor() {
        super('advice', {
            aliases: ['advice'],
            category: 'fun',
            description: {
                content: 'Gives you a random piece of advice.',
                usage: '',
                examples: [
                    ''
                ]
            },
            ratelimit: 3
        });
    }
    
    public async exec(msg: Message): Promise<Message> {
        const response = await Axios.get('http://api.adviceslip.com/advice').catch(err => {
            console.error(err);
            return msg.reply('Woops, there was an error regarding the (http://numbersapi.com) API.');
        });
        //@ts-ignore
        return msg.reply(response.data.slip.advice);
    }
}