aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIndrajith K L2021-05-26 01:46:01 +0530
committerIndrajith K L2021-05-26 01:46:01 +0530
commit717a38d6b7cd20d2d7b9904dfeea9b29302900aa (patch)
tree3758e80ce0e43938e85fcbc27976843ed888d6e7 /src
parent187e6bc1f221f5b4a4cb5a2ebe6ddb66780cc2d8 (diff)
downloadradio-bot-717a38d6b7cd20d2d7b9904dfeea9b29302900aa.tar.gz
radio-bot-717a38d6b7cd20d2d7b9904dfeea9b29302900aa.tar.bz2
radio-bot-717a38d6b7cd20d2d7b9904dfeea9b29302900aa.zip
:sparkles: Add New Command `gt` - Game of Thrones Random Quotes
Diffstat (limited to 'src')
-rw-r--r--src/commands/gt.js28
-rw-r--r--src/configs/commands.config.json5
2 files changed, 33 insertions, 0 deletions
diff --git a/src/commands/gt.js b/src/commands/gt.js
new file mode 100644
index 0000000..512e76b
--- /dev/null
+++ b/src/commands/gt.js
@@ -0,0 +1,28 @@
+const axios = require('axios').default;
+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 randomQuoteMessage = new MessageEmbed()
+ .setDescription(sentence)
+ .setFooter(`${name}, ${houseName}`);
+ message.channel.send(randomQuoteMessage);
+ } catch(error) {
+ const errorMessage = new MessageEmbed()
+ .setTitle("Something went wrong: Error getting quotes from Arya Stark")
+ .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/configs/commands.config.json b/src/configs/commands.config.json
index 282de6e..268d889 100644
--- a/src/configs/commands.config.json
+++ b/src/configs/commands.config.json
@@ -24,6 +24,11 @@
"name": "vaccine",
"description": "Get Vaccine Availability by Pincode",
"file": "./commands/vaccine.js"
+ },
+ {
+ "name": "gt",
+ "description": "Game of Thrones Quotes",
+ "file": "./commands/gt.js"
}
]
} \ No newline at end of file