forked from Supositware/Haha-Yes
Send image as attachment when the message is only a link
This commit is contained in:
parent
be34506063
commit
79b9763159
1 changed files with 12 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
const { Listener } = require('discord-akairo');
|
const { Listener } = require('discord-akairo');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const reload = require('auto-reload');
|
const reload = require('auto-reload');
|
||||||
|
const getUrls = require('get-urls');
|
||||||
let messageID = require('../../json/starboard.json');
|
let messageID = require('../../json/starboard.json');
|
||||||
|
|
||||||
class MessageReactionAddListener extends Listener {
|
class MessageReactionAddListener extends Listener {
|
||||||
|
@ -14,6 +15,7 @@ class MessageReactionAddListener extends Listener {
|
||||||
async exec(reaction) {
|
async exec(reaction) {
|
||||||
let messageContent = reaction.message.content;
|
let messageContent = reaction.message.content;
|
||||||
let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`);
|
let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`);
|
||||||
|
let URL = [...getUrls(messageContent)];
|
||||||
|
|
||||||
let starboardChannel;
|
let starboardChannel;
|
||||||
let staremote;
|
let staremote;
|
||||||
|
@ -49,6 +51,11 @@ class MessageReactionAddListener extends Listener {
|
||||||
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL())
|
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL())
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (URL) {
|
||||||
|
return channel.send(`in: ${reaction.message.channel}\nhttps://discordapp.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id}`, {files: [URL[0]]})
|
||||||
|
.catch(() => channel.send(`${reaction.message.author.username}, in: ${reaction.message.channel}\n${URL[0]}`));
|
||||||
|
}
|
||||||
|
|
||||||
return channel.send(`in: ${reaction.message.channel}`, {files: messageAttachments, embed: starEmbed})
|
return channel.send(`in: ${reaction.message.channel}`, {files: messageAttachments, embed: starEmbed})
|
||||||
.catch(() => channel.send(`${reaction.message.author.username}, in: ${reaction.message.channel}`, { embed: starEmbed}));
|
.catch(() => channel.send(`${reaction.message.author.username}, in: ${reaction.message.channel}`, { embed: starEmbed}));
|
||||||
}
|
}
|
||||||
|
@ -87,6 +94,11 @@ class MessageReactionAddListener extends Listener {
|
||||||
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL())
|
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL())
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (URL) {
|
||||||
|
return channel.send(`in: ${reaction.message.channel}\nhttps://discordapp.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id}`, {files: [URL[0]]})
|
||||||
|
.catch(() => channel.send(`${reaction.message.author.username}, in: ${reaction.message.channel}\n${URL[0]}`));
|
||||||
|
}
|
||||||
|
|
||||||
return channel.send(`in: ${reaction.message.channel}`,{files: messageAttachments, embed: shameEmbed})
|
return channel.send(`in: ${reaction.message.channel}`,{files: messageAttachments, embed: shameEmbed})
|
||||||
.catch(() => channel.send(`${reaction.message.author.username}, in: ${reaction.message.channel}`, { embed: shameEmbed}));
|
.catch(() => channel.send(`${reaction.message.author.username}, in: ${reaction.message.channel}`, { embed: shameEmbed}));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue