Check if the message is in starboard before attempting to delete it

This commit is contained in:
loicbersier 2019-12-27 22:02:03 +01:00
parent 331de1784f
commit 3d0448b588

View file

@ -25,7 +25,7 @@ class messageReactionRemoveListener extends Listener {
staremote = this.client.util.resolveEmoji(staremote, reaction.message.guild.emojis).name; staremote = this.client.util.resolveEmoji(staremote, reaction.message.guild.emojis).name;
} }
if (reaction.emoji.name == staremote && reaction.count < starcount) { if (messageID[reaction.message.id] && reaction.emoji.name == staremote && reaction.count < starcount) {
let channel = this.client.channels.get(starboardChannel.starboard); let channel = this.client.channels.get(starboardChannel.starboard);
let message = await channel.messages.get(messageID[reaction.message.id]); let message = await channel.messages.get(messageID[reaction.message.id]);
message.delete(); message.delete();
@ -45,7 +45,7 @@ class messageReactionRemoveListener extends Listener {
shameemote = this.client.util.resolveEmoji(shameemote, reaction.message.guild.emojis).name; shameemote = this.client.util.resolveEmoji(shameemote, reaction.message.guild.emojis).name;
} }
if (reaction.emoji.name == shameemote && reaction.count < shamecount) { if (messageID[reaction.message.id] && reaction.emoji.name == shameemote && reaction.count < shamecount) {
let channel = this.client.channels.get(shameboardChannel.shameboard); let channel = this.client.channels.get(shameboardChannel.shameboard);
let message = await channel.messages.get(messageID[reaction.message.id]); let message = await channel.messages.get(messageID[reaction.message.id]);
message.delete(); message.delete();