From 3b2511341739c3717ce0d82a8a6dc9064610720d Mon Sep 17 00:00:00 2001 From: Danial Raza Date: Sat, 24 Feb 2024 03:04:13 +0100 Subject: [PATCH] fix(Embed): address `equals` method issue --- packages/discord.js/src/structures/Embed.js | 25 +++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/discord.js/src/structures/Embed.js b/packages/discord.js/src/structures/Embed.js index dd68120d955b5..0c2ff914ce49f 100644 --- a/packages/discord.js/src/structures/Embed.js +++ b/packages/discord.js/src/structures/Embed.js @@ -211,9 +211,30 @@ class Embed { */ equals(other) { if (other instanceof Embed) { - return isEqual(other.data, this.data); + return isEqual(this.data, other.data); } - return isEqual(other, this.data); + + return ( + this.color === (other.color ?? null) && + this.description === (other.description ?? null) && + this.title === (other.title ?? null) && + this.url === (other.url ?? null) && + (this.timestamp ? new Date(this.timestamp).getTime() : null) === + (other.timestamp ? new Date(other.timestamp).getTime() : null) && + this.data.image?.url === other.image?.url && + this.data.thumbnail?.url === other.thumbnail?.url && + this.data.video?.url === other.video?.url && + isEqual(this.fields, other.fields?.map(field => ({ ...field, inline: field.inline ?? false })) ?? []) && + isEqual(this.provider, other.provider ?? null) && + isEqual( + { icon_url: this.author?.iconURL, name: this.author?.name, url: this.author?.url }, + { icon_url: other.author?.icon_url, name: other.author?.name, url: other.author?.url }, + ) && + isEqual( + { icon_url: this.footer?.iconURL, text: this.footer?.text }, + { icon_url: other.footer?.icon_url, text: other.footer?.text }, + ) + ); } }