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

Add EmbedField object to allow for easier embed class instance creation #1181

Merged
merged 29 commits into from Apr 17, 2022
Merged

Add EmbedField object to allow for easier embed class instance creation #1181

merged 29 commits into from Apr 17, 2022

Conversation

krittick
Copy link
Contributor

@krittick krittick commented Mar 18, 2022

Summary

This adds a new object EmbedField, which corresponds to the object of the same name in the API Documentation. This also follows the same conventions used by other libraries (i.e. treating EmbedField as a higher level object), such as discord.js, DisCatSharp, and many others.

A parameter fields has also been added to the __init__ method for the Embed class, which allows passing a list of EmbedField objects when creating a new embed, instead of needing to use Embed.add_field() for each field. It also adds a setter for the fields property which accomplishes the same thing for existing embeds.

This is a breaking change only if you were somehow using the private _EmbedFieldProxy class for anything, as this has now been removed in favor of EmbedField.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)

@krittick krittick self-assigned this Mar 18, 2022
@krittick krittick added priority: low Low Priority status: in progress Work in Progess feature Implements a feature labels Mar 18, 2022
@krittick krittick added this to In progress in v2.0 via automation Mar 18, 2022
@krittick krittick added this to the v2.0 milestone Mar 18, 2022
@plun1331
Copy link
Member

Embed.fields could be changed to return EmbedField instead of EmbedProxy

discord/embeds.py Show resolved Hide resolved
@krittick
Copy link
Contributor Author

Embed.fields could be changed to return EmbedField instead of EmbedProxy

That's my plan as part of this PR, just haven't gotten there yet.

fix typing for fields parameter in Embed.__init__
fix typing for Embed.fields property
change Embed.add_field, Embed.insert_field_at to use an EmbedField object when appending to Embed._fields
change Embed.set_field_at to set EmbedField properties instead of dictionary values
@krittick
Copy link
Contributor Author

krittick commented Apr 9, 2022

This is now ready for review.

EmreTech
EmreTech previously approved these changes Apr 9, 2022
Lulalaby
Lulalaby previously approved these changes Apr 11, 2022
@krittick krittick dismissed stale reviews from Lulalaby and EmreTech via 0c097cf April 12, 2022 08:10
@krittick krittick requested a review from Lulalaby April 12, 2022 08:30
Lulalaby
Lulalaby previously approved these changes Apr 12, 2022
Copy link
Member

@Dorukyum Dorukyum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add versionadded to the new class and the new methods.

discord/embeds.py Show resolved Hide resolved
discord/embeds.py Show resolved Hide resolved
@krittick krittick merged commit 427cbd4 into Pycord-Development:master Apr 17, 2022
v2.0 automation moved this from In progress to Done Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Implements a feature priority: low Low Priority status: awaiting review Awaiting review from a maintainer
Projects
Status: No status
v2.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants