aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIndrajith K L2021-05-26 23:18:24 +0530
committerIndrajith K L2021-05-26 23:18:24 +0530
commit4e86dbd1755db4ff8a1779fda8c3a167d1b24c8e (patch)
treece7a412f1739089a503e8736cb6914cb9d3a97ec /src
parent77684697abb223fe3b06655da27683a466121ed2 (diff)
downloadradio-bot-4e86dbd1755db4ff8a1779fda8c3a167d1b24c8e.tar.gz
radio-bot-4e86dbd1755db4ff8a1779fda8c3a167d1b24c8e.tar.bz2
radio-bot-4e86dbd1755db4ff8a1779fda8c3a167d1b24c8e.zip
Adds New Command for Dark Series Quotes
command: !dark
Diffstat (limited to 'src')
-rw-r--r--src/commands/dark.js29
-rw-r--r--src/configs/commands.config.json5
2 files changed, 34 insertions, 0 deletions
diff --git a/src/commands/dark.js b/src/commands/dark.js
new file mode 100644
index 0000000..54a486d
--- /dev/null
+++ b/src/commands/dark.js
@@ -0,0 +1,29 @@
+const axios = require('axios').default;
+const { MessageEmbed } = require('discord.js');
+const instance = axios.create({
+ baseURL: 'https://dark-api.herokuapp.com/api/v1'
+});
+
+async function getRandomQuotes(message, args) {
+ const randomQuotesUrl = "/quote/random";
+ try {
+ const result = await instance.get(randomQuotesUrl);
+ const { author, season, episode, quote } = result.data;
+ const randomQuoteMessage = new MessageEmbed()
+ .setDescription(quote)
+ .setFooter(`${author}, S${season} : Episode - ${episode}`);
+ message.channel.send(randomQuoteMessage);
+ } catch (error) {
+ const errorMessage = new MessageEmbed()
+ .setTitle("Something went wrong: Error getting quotes from Mikkel Nielsen")
+ .setColor("RED");
+ message.channel.send(errorMessage);
+ }
+}
+
+module.exports = {
+ execute(client, message, args) {
+ getRandomQuotes(message, args);
+ }
+}
+
diff --git a/src/configs/commands.config.json b/src/configs/commands.config.json
index 23435b1..af4da0d 100644
--- a/src/configs/commands.config.json
+++ b/src/configs/commands.config.json
@@ -34,6 +34,11 @@
"name": "bb",
"description": "Breaking Bad Quotes",
"file": "./commands/bb.js"
+ },
+ {
+ "name": "dark",
+ "description": "Dark Series Quotes",
+ "file": "./commands/dark.js"
}
]
} \ No newline at end of file