From 4e86dbd1755db4ff8a1779fda8c3a167d1b24c8e Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Wed, 26 May 2021 23:18:24 +0530 Subject: Adds New Command for Dark Series Quotes command: !dark --- src/commands/dark.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/commands/dark.js (limited to 'src/commands') 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); + } +} + -- cgit v1.2.3