aboutsummaryrefslogtreecommitdiff
path: root/src/commands/bb.js
blob: bfd0c3a73d7af8439bdde512e5b0e55a2f8d626c (plain)
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
const axios = require('axios').default;
const { MessageEmbed } = require('discord.js');
const instance = axios.create({
    baseURL: 'https://breaking-bad-quotes.herokuapp.com/v1'
});

async function getRandomQuotes(message, args) {
    const randomQuotesUrl = "/quotes";
    try {
        const result = await instance.get(randomQuotesUrl);
        const { quote, author } = result.data[0];
        const randomQuoteMessage = new MessageEmbed()
            .setDescription(quote)
            .setFooter(`${author}`);
        message.channel.send(randomQuoteMessage);
    } catch (error) {
        const errorMessage = new MessageEmbed()
            .setTitle("Stay out of territory: Error getting quotes from Walter White")
            .setColor("RED");
        message.channel.send(errorMessage);
    }
}

module.exports = {
    execute(client, message, args) {
        getRandomQuotes(message, args);
    }
}