From 6fa84b1e4ab9164c8ef67e869a79f4d75ac715f9 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 31 Dec 2019 12:12:35 +0100 Subject: [PATCH] Don't make embed undefined on edit if it doesn't have a description --- event/listeners/messageReactionAdd.js | 6 +++++- event/listeners/messageReactionRemove.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/event/listeners/messageReactionAdd.js b/event/listeners/messageReactionAdd.js index 4fbc7a9..201adef 100644 --- a/event/listeners/messageReactionAdd.js +++ b/event/listeners/messageReactionAdd.js @@ -79,13 +79,17 @@ class MessageReactionAddListener extends Listener { } let message = await channel.messages.get(boardID); + // If the original embed description is empty make this embed empty ( and not undefined ) + let description; + if (message.embeds[0].description == undefined) + description = ''; let Embed = client.util.embed() .setColor(reaction.message.member.displayHexColor) .setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL()) .addField('Jump to', `[message](https://discordapp.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id})`, true) .addField('Channel', reaction.message.channel, true) - .setDescription(message.embeds[0].description) + .setDescription(description) .setFooter(reactionCount + ' ' + emote) .setTimestamp(); diff --git a/event/listeners/messageReactionRemove.js b/event/listeners/messageReactionRemove.js index 50b73b6..a9e9ba0 100644 --- a/event/listeners/messageReactionRemove.js +++ b/event/listeners/messageReactionRemove.js @@ -77,13 +77,17 @@ class messageReactionRemoveListener extends Listener { } let message = await channel.messages.get(boardID); + // If the original embed description is empty make this embed empty ( and not undefined ) + let description; + if (message.embeds[0].description == undefined) + description = ''; let Embed = client.util.embed() .setColor(reaction.message.member.displayHexColor) .setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL()) .addField('Jump to', `[message](https://discordapp.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id})`, true) .addField('Channel', reaction.message.channel, true) - .setDescription(message.embeds[0].description) + .setDescription(description) .setFooter(reactionCount + ' ' + emote) .setTimestamp();