You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Represents a embed in a message (image/video preview, rich embed, etc.)
*/
exportclassEmbedBuilder{
publicreadonlydata: APIEmbed;
We can see this is an APIEmbed. Therefore, these should be comparable. However, comparisons here will never be equal, as received embeds from Discord have a type property which is not present during construction.
The code sample contains a console.log(), of which the output is:
The internally-called isEqual() method is derived from fast-deep-equal which compares the number of object keys, thus introducing this bug (view source code here).
An important mention here is that this is not limited to Discord's returned type property. Field inline values are optional whereas Discord will always return them, causing a mismatch of the length of keys. Additionally, what if Discord creates a new property on an embed? As soon as their API deployment is done, this method will begin failing despite no changes in discord.js.
Which package is this bug report for?
discord.js
Issue description
Here is the definition for
Embed#equals()
:discord.js/packages/discord.js/src/structures/Embed.js
Lines 207 to 217 in 8b70f49
This may take an
APIEmbed
. Looking atEmbedBuilder#data
:discord.js/packages/builders/src/messages/embed/Embed.ts
Lines 43 to 47 in 8b70f49
We can see this is an
APIEmbed
. Therefore, these should be comparable. However, comparisons here will never be equal, as received embeds from Discord have atype
property which is not present during construction.The code sample contains a
console.log()
, of which the output is:The internally-called
isEqual()
method is derived from fast-deep-equal which compares the number of object keys, thus introducing this bug (view source code here).An important mention here is that this is not limited to Discord's returned
type
property. Fieldinline
values are optional whereas Discord will always return them, causing a mismatch of the length of keys. Additionally, what if Discord creates a new property on an embed? As soon as their API deployment is done, this method will begin failing despite no changes in discord.js.Code sample
Package version
14.7.2-dev
Node.js version
Node.js 18.13.0 & typescript 4.9.4
Operating system
macOS Ventura 13.1
Priority this issue should have
Medium (should be fixed soon)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
Guilds
I have tested this issue on a development release
8b70f49
The text was updated successfully, but these errors were encountered: