From 4f583f4caf537ca1897aa8171040ca632865fc30 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 29 Feb 2020 18:13:41 +0100 Subject: [PATCH] Show images from link --- event/listeners/messageReactionAdd.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/event/listeners/messageReactionAdd.js b/event/listeners/messageReactionAdd.js index 85f6c5e1..36e5d688 100644 --- a/event/listeners/messageReactionAdd.js +++ b/event/listeners/messageReactionAdd.js @@ -105,7 +105,7 @@ class MessageReactionAddListener extends Listener { } async function sendEmbed(name, emote, client) { - let messageAttachments = reaction.message.attachments.map(u=> u.url); + let messageAttachments = reaction.message.attachments.map(u=> u.url)[0]; // Should change this so it automatically pic the channel ( I'm lazy right now ) let channel; if (name == 'starboard') { @@ -127,31 +127,36 @@ class MessageReactionAddListener extends Listener { } let description = ''; - console.log(reaction.message.content); - // if message come from nsfw channel and the star/shameboard channel isn't nsfw put it in spoiler + if (reaction.message.embeds[0]) { + console.log(reaction.message.embeds[0].url); + if (reaction.message.embeds[0].type == 'image') { + messageAttachments = reaction.message.embeds[0].url; + } + if (reaction.message.embeds[0].description) { description = reaction.message.embeds[0].description; + } else if (reaction.message.content) { + description = reaction.message.content; } - } - else if (reaction.message.content) { + } else if (reaction.message.content) { description = reaction.message.content; } - + + // if message come from nsfw channel and the star/shameboard channel isn't nsfw put it in spoiler if (reaction.message.channel.nsfw && !channel.nsfw) { Embed.setDescription(`||${description}||`); if (messageAttachments != '') { let message = await channel.send(`||${messageAttachments}||`, { embed: Embed }); messageID[reaction.message.id] = message.id; - } - else { + } else { let message = await channel.send({embed: Embed}); messageID[reaction.message.id] = message.id; } } else { Embed.setDescription(description); - let message = await channel.send({ files: messageAttachments, embed: Embed }) - .catch(async () => channel.send(messageAttachments, { embed: Embed })); + let message = await channel.send({ files: [messageAttachments], embed: Embed }) + .catch(async () => channel.send(messageAttachments, { embed: Embed })); messageID[reaction.message.id] = message.id; } }