Adds New Command for Breaking Bad Quotes
command: !bb
This commit is contained in:
28
src/commands/bb.js
Normal file
28
src/commands/bb.js
Normal file
@@ -0,0 +1,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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,11 @@
|
|||||||
"name": "got",
|
"name": "got",
|
||||||
"description": "Game of Thrones Quotes",
|
"description": "Game of Thrones Quotes",
|
||||||
"file": "./commands/got.js"
|
"file": "./commands/got.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bb",
|
||||||
|
"description": "Breaking Bad Quotes",
|
||||||
|
"file": "./commands/bb.js"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user