aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/gt.js28
1 files changed, 28 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