aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIndrajith K L2021-05-26 23:09:34 +0530
committerIndrajith K L2021-05-26 23:09:34 +0530
commit77684697abb223fe3b06655da27683a466121ed2 (patch)
treeffe86865f269a17788cff2bb8eb7abaf211dc9b4 /src
parentc895e9f5fe9ed0eb11f6b2dc239a05365cfd3975 (diff)
downloadlul-bot-77684697abb223fe3b06655da27683a466121ed2.tar.gz
lul-bot-77684697abb223fe3b06655da27683a466121ed2.tar.bz2
lul-bot-77684697abb223fe3b06655da27683a466121ed2.zip
Adds New Command for Breaking Bad Quotes
command: !bb
Diffstat (limited to 'src')
-rw-r--r--src/commands/bb.js28
-rw-r--r--src/commands/got.js16
-rw-r--r--src/configs/commands.config.json5
3 files changed, 41 insertions, 8 deletions
diff --git a/src/commands/bb.js b/src/commands/bb.js
new file mode 100644
index 0000000..bfd0c3a
--- /dev/null
+++ b/src/commands/bb.js
@@ -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);
+ }
+} \ No newline at end of file
diff --git a/src/commands/got.js b/src/commands/got.js
index 512e76b..bfb9295 100644
--- a/src/commands/got.js
+++ b/src/commands/got.js
@@ -1,22 +1,22 @@
const axios = require('axios').default;
-const {MessageEmbed} = require('discord.js');
+const { MessageEmbed } = require('discord.js');
const instance = axios.create({
baseURL: 'https://game-of-thrones-quotes.herokuapp.com/v1'
- });
+});
async function getRandomQuotes(message, args) {
const randomQuotesUrl = "/random";
try {
const result = await instance.get(randomQuotesUrl);
- const {sentence, character: {name, house: {name:houseName}}} = result.data;
+ const { sentence, character: { name, house: { name: houseName } } } = result.data;
const randomQuoteMessage = new MessageEmbed()
- .setDescription(sentence)
- .setFooter(`${name}, ${houseName}`);
+ .setDescription(sentence)
+ .setFooter(`${name}, ${houseName}`);
message.channel.send(randomQuoteMessage);
- } catch(error) {
+ } catch (error) {
const errorMessage = new MessageEmbed()
- .setTitle("Something went wrong: Error getting quotes from Arya Stark")
- .setColor("RED");
+ .setTitle("Something went wrong: Error getting quotes from Arya Stark")
+ .setColor("RED");
message.channel.send(errorMessage);
}
}
diff --git a/src/configs/commands.config.json b/src/configs/commands.config.json
index 1c448c9..23435b1 100644
--- a/src/configs/commands.config.json
+++ b/src/configs/commands.config.json
@@ -29,6 +29,11 @@
"name": "got",
"description": "Game of Thrones Quotes",
"file": "./commands/got.js"
+ },
+ {
+ "name": "bb",
+ "description": "Breaking Bad Quotes",
+ "file": "./commands/bb.js"
}
]
} \ No newline at end of file