From e3dba82cf3cdbdf5c0aad3d308013695a2074ecf Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 27 Mar 2021 21:57:16 +0530 Subject: Code Refactoring * Adds Config for commands * Moved Casual Messages to language.json --- src/commons/confusion.js | 22 ++++++++++++++++++++++ src/commons/jokes.js | 7 ------- 2 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 src/commons/confusion.js delete mode 100644 src/commons/jokes.js (limited to 'src/commons') diff --git a/src/commons/confusion.js b/src/commons/confusion.js new file mode 100644 index 0000000..7a5d9b8 --- /dev/null +++ b/src/commons/confusion.js @@ -0,0 +1,22 @@ +const {MessageEmbed} = require('discord.js'); +const fetch = require('node-fetch'); +function generateConfusionGif(message) { + message.channel.startTyping(); + const embed = new MessageEmbed() + .setDescription(`I dont understand what you are saying <@${process.env.KLIAS_TAG}> do you know what this guy is asking?`) + .setColor("RANDOM"); + const randomIndex = Math.floor(Math.random() * 49); + fetch(`https://api.tenor.com/v1/random?key=${process.env.TENOR_TOKEN}&q=I%20dont%20understand&limit=50`) + .then(res => res.json()) + .then(response => { + embed.setImage(response.results[randomIndex].media[0].gif.url); + message.channel.stopTyping(); + message.channel.send(embed); + }); +} + +module.exports = { + execute(message) { + generateConfusionGif(message); + } +} \ No newline at end of file diff --git a/src/commons/jokes.js b/src/commons/jokes.js deleted file mode 100644 index 261cacb..0000000 --- a/src/commons/jokes.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - name: "jokes", - description: "Only bad jokes here", - execute() { - - } -} \ No newline at end of file -- cgit v1.2.3