From 518ec431d8ab329db087da2484b0dfaf64f6ab00 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 28 May 2022 12:55:23 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20more=20logical=20meme=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/modules/{meme.ts => meme/index.ts} | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) rename src/plugins/fun/modules/{meme.ts => meme/index.ts} (57%) diff --git a/src/plugins/fun/modules/meme.ts b/src/plugins/fun/modules/meme/index.ts similarity index 57% rename from src/plugins/fun/modules/meme.ts rename to src/plugins/fun/modules/meme/index.ts index be62672..4efe8a7 100644 --- a/src/plugins/fun/modules/meme.ts +++ b/src/plugins/fun/modules/meme/index.ts @@ -11,11 +11,12 @@ export default { builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("meme").setDescription("Get a meme from r/memes)"); }, + execute: async (interaction: CommandInteraction) => { - if (interaction.guild == null) return; - const { successColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); + const { guild } = interaction; + + const embedConfig = await getEmbedConfig(guild); + await axios .get("https://www.reddit.com/r/memes/random/.json") .then(async (res) => { @@ -23,14 +24,28 @@ export default { const content = response[0].data; const embed = new MessageEmbed() - .setTitle(content.title) + .setAuthor({ + name: content.title, + iconURL: + "https://www.redditinc.com/assets/images/site/reddit-logo.png", + url: `https://reddit.com${content.permalink}`, + }) + .setTitle("[:sweat_smile:] Meme") + .addFields([ + { name: "Author", value: content.author, inline: true }, + { + name: "Votes", + value: `${content.ups}/${content.downs}`, + inline: true, + }, + ]) .setTimestamp(new Date()) .setImage(content.url) .setFooter({ - text: `👍 ${content.ups}︱👎 ${content.downs}\n${footerText}`, - iconURL: footerIcon, + text: embedConfig.footerText, + iconURL: embedConfig.footerIcon, }) - .setColor(successColor); + .setColor(embedConfig.successColor); return interaction.editReply({ embeds: [embed] }); })