diff --git a/json/starboard.json b/json/starboard.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/json/starboard.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/listeners/messageReactionAdd.js b/listeners/messageReactionAdd.js index a1c82574..4f94af4e 100644 --- a/listeners/messageReactionAdd.js +++ b/listeners/messageReactionAdd.js @@ -1,6 +1,7 @@ const { Listener } = require('discord-akairo'); const { MessageEmbed } = require('discord.js'); const reload = require('auto-reload'); +let messageID = require('../json/starboard.json'); class MessageReactionAddListener extends Listener { constructor() { @@ -15,6 +16,11 @@ class MessageReactionAddListener extends Listener { let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`); if (reaction.emoji.name === '🌟' && reaction.count === 4) { + if (messageID.includes(reaction.message.id)) + return console.log('Message already in starboard!'); + + messageID.push(reaction.message.id); + let starboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`); const channel = this.client.channels.get(starboardChannel['starboard']); @@ -25,9 +31,14 @@ class MessageReactionAddListener extends Listener { .setTimestamp(); channel.send({ embed: starEmbed}); - return channel.send(`From: ${reaction.message.channel}\n${messageAttachments}`); + return channel.send(`From: ${reaction.message.channel} ID: ${reaction.message.id} \n${messageAttachments}`); } if (reaction.emoji.name === '✡' && reaction.count === 4) { + if (messageID.includes(reaction.message.id)) + return console.log('Message already in starboard!'); + + messageID.push(reaction.message.id); + let shameboardChannel = reload(`../starboard/${message.guild.id}.json`); const channel = client.channels.get(shameboardChannel['shameboard']);