From 29413cd3552e9ab1d310cbae0fc62208d5a464c4 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 19 Jan 2020 13:35:47 +0100 Subject: [PATCH] Fixed multiple errors about the boards --- event/listeners/messageReactionAdd.js | 9 ++++++--- event/listeners/messageReactionRemove.js | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/event/listeners/messageReactionAdd.js b/event/listeners/messageReactionAdd.js index cb510987..a6349768 100644 --- a/event/listeners/messageReactionAdd.js +++ b/event/listeners/messageReactionAdd.js @@ -78,8 +78,11 @@ class MessageReactionAddListener extends Listener { channel = client.channels.get(shameboardChannel.shameboard); } - reaction.message.fetch(boardID); let message = await channel.messages.get(boardID); + + // If the message doesn't have embeds assume it got deleted so don't do anything + if (!message) return; + // If the original embed description is empty make this embed empty ( and not undefined ) let description = message.embeds[0].description; if (!message.embeds[0].description) @@ -125,9 +128,9 @@ class MessageReactionAddListener extends Listener { let 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.content && reaction.message.embeds[0].description) + if (!reaction.message.content && reaction.message.embeds[0]) description = reaction.message.embeds[0].description; - else if (!reaction.message.content && !reaction.message.embeds[0].description) + else if (!reaction.message.content) description = ''; if (reaction.message.channel.nsfw && !channel.nsfw) { diff --git a/event/listeners/messageReactionRemove.js b/event/listeners/messageReactionRemove.js index 01856f79..73805e24 100644 --- a/event/listeners/messageReactionRemove.js +++ b/event/listeners/messageReactionRemove.js @@ -41,6 +41,9 @@ class messageReactionRemoveListener extends Listener { let channel = this.client.channels.get(starboardChannel.starboard); let message = await channel.messages.get(messageID[reaction.message.id]); delete messageID[reaction.message.id]; + // If it didn't find any message don't do anything + if (!message) return; + message.delete(); } else if (reaction.emoji.name == staremote && reactionCount >= starcount) { return editEmbed('starboard', staremote, messageID[reaction.message.id], this.client); @@ -76,8 +79,11 @@ class messageReactionRemoveListener extends Listener { channel = client.channels.get(shameboardChannel.shameboard); } - reaction.message.fetch(boardID); let message = await channel.messages.get(boardID); + console.log(message); + // If the message doesn't have embeds assume it got deleted so don't do anything + if (!message) return; + // If the original embed description is empty make this embed empty ( and not undefined ) let description = message.embeds[0].description; if (!message.embeds[0].description)