Show images from link

This commit is contained in:
loicbersier 2020-02-29 18:13:41 +01:00
parent a607a59816
commit 4f583f4caf

View file

@ -105,7 +105,7 @@ class MessageReactionAddListener extends Listener {
} }
async function sendEmbed(name, emote, client) { 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 ) // Should change this so it automatically pic the channel ( I'm lazy right now )
let channel; let channel;
if (name == 'starboard') { if (name == 'starboard') {
@ -127,30 +127,35 @@ class MessageReactionAddListener extends Listener {
} }
let description = ''; 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]) { 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) { if (reaction.message.embeds[0].description) {
description = 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; 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) { if (reaction.message.channel.nsfw && !channel.nsfw) {
Embed.setDescription(`||${description}||`); Embed.setDescription(`||${description}||`);
if (messageAttachments != '') { if (messageAttachments != '') {
let message = await channel.send(`||${messageAttachments}||`, { embed: Embed }); let message = await channel.send(`||${messageAttachments}||`, { embed: Embed });
messageID[reaction.message.id] = message.id; messageID[reaction.message.id] = message.id;
} } else {
else {
let message = await channel.send({embed: Embed}); let message = await channel.send({embed: Embed});
messageID[reaction.message.id] = message.id; messageID[reaction.message.id] = message.id;
} }
} else { } else {
Embed.setDescription(description); Embed.setDescription(description);
let message = await channel.send({ files: messageAttachments, embed: Embed }) let message = await channel.send({ files: [messageAttachments], embed: Embed })
.catch(async () => channel.send(messageAttachments, { embed: Embed })); .catch(async () => channel.send(messageAttachments, { embed: Embed }));
messageID[reaction.message.id] = message.id; messageID[reaction.message.id] = message.id;
} }