Skip to content

Commit

Permalink
fix(Embed): address equals method issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sdanialraza committed Feb 24, 2024
1 parent efa3cac commit 3b25113
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions packages/discord.js/src/structures/Embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
)
);
}
}

Expand Down

0 comments on commit 3b25113

Please sign in to comment.