From c895e9f5fe9ed0eb11f6b2dc239a05365cfd3975 Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Wed, 26 May 2021 22:44:34 +0530 Subject: Renamed gt command to got --- src/commands/got.js | 28 ++++++++++++++++++++++++++++ src/commands/gt.js | 28 ---------------------------- src/configs/commands.config.json | 4 ++-- 3 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 src/commands/got.js delete mode 100644 src/commands/gt.js diff --git a/src/commands/got.js b/src/commands/got.js new file mode 100644 index 0000000..512e76b --- /dev/null +++ b/src/commands/got.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/commands/gt.js b/src/commands/gt.js deleted file mode 100644 index 512e76b..0000000 --- a/src/commands/gt.js +++ /dev/null @@ -1,28 +0,0 @@ -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 268d889..1c448c9 100644 --- a/src/configs/commands.config.json +++ b/src/configs/commands.config.json @@ -26,9 +26,9 @@ "file": "./commands/vaccine.js" }, { - "name": "gt", + "name": "got", "description": "Game of Thrones Quotes", - "file": "./commands/gt.js" + "file": "./commands/got.js" } ] } \ No newline at end of file -- cgit v1.2.3