Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(MessageEmbed): add #equals #6885

Merged
merged 2 commits into from Oct 27, 2021
Merged

Conversation

ImRodry
Copy link
Contributor

@ImRodry ImRodry commented Oct 25, 2021

Please describe the changes this PR makes and why it should be merged:
This PR adds the MessageEmbed#equals and the MessageEmbed#_fieldEquals methods (the latter being private) in order to allow for the comparison of two embed objects (while also accepting raw API embed objects). I stumbled across a scenario in one of my projects where I had to compare two embeds entirely so I figured I might as well add this to the library itself.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)

@wutv
Copy link
Contributor

wutv commented Oct 25, 2021

image
serialize being v8.serialize

@ImRodry
Copy link
Contributor Author

ImRodry commented Oct 25, 2021

What is that supposed to mean @wutv

@wutv
Copy link
Contributor

wutv commented Oct 25, 2021

What is that supposed to mean @wutv

your code seems slightly unnecessary

@wutv
Copy link
Contributor

wutv commented Oct 25, 2021

that function basically has the same purpose as yours, except its smaller

@ImRodry
Copy link
Contributor Author

ImRodry commented Oct 25, 2021

Ok now try comparing two real embeds that are equal but attached to different objects. That's the point of this function and functions like this exist across the library so please show me better examples

@GodderE2D
Copy link
Contributor

May I ask why _fieldEquals is private?

@ImRodry
Copy link
Contributor Author

ImRodry commented Oct 25, 2021

May I ask why _fieldEquals is private?

To be consistent with other methods such as ApplicationCommand#_optionEquals and because it doesn’t really make any difference since you can simply access it through MessageEmbed._fieldEquals, even in typescript I believe

@iCrawl iCrawl added this to the Version 13.3 milestone Oct 26, 2021
src/structures/MessageEmbed.js Show resolved Hide resolved
src/structures/MessageEmbed.js Show resolved Hide resolved
typings/index.d.ts Show resolved Hide resolved
@iCrawl iCrawl merged commit fae4abf into discordjs:main Oct 27, 2021
@ImRodry ImRodry deleted the feat-embed-equals branch October 27, 2021 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants