Skip to content

Conversation

valzargaming
Copy link
Member

This pull request refactors and extends the embed system in the DiscordPHP project to support multiple embed types and improve type safety for embed attributes. It introduces dedicated classes for each embed type, updates property definitions for better nullability and documentation, and adds support for new embed structures like Provider and Thumbnail.

Embed system refactoring and type support

  • Added dedicated classes for each embed type (EmbedRich, EmbedImage, EmbedVideo, EmbedGifv, EmbedArticle, EmbedLink, EmbedPollResult) and a type mapping in Embed::TYPES to instantiate the correct class based on the embed's type. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Updated the embed type handling in Message.php to use the new type mapping for instantiating embed objects.
  • Added support for the new poll_result embed type in the embed types list.

Attribute and property improvements

  • Improved property nullability and documentation for embed-related classes (Embed, Author, Footer, Field, Image, Video) to use ?type|null for optional properties and updated docblocks for accuracy. [1] [2] [3] [4] [5] [6]
  • Changed the thumbnail attribute in Embed to use the new Thumbnail class instead of Image, and added a getter for the new Provider attribute. [1] [2]

New embed structure classes

  • Added new classes for Provider and Thumbnail to represent their respective embed structures, with appropriate fillable fields and documentation. [1] [2]

@valzargaming
Copy link
Member Author

Still need to add the valid fields for each type as a const array to those classes

@valzargaming valzargaming marked this pull request as ready for review September 1, 2025 16:15
Copy link
Member Author

@valzargaming valzargaming Sep 1, 2025

Choose a reason for hiding this comment

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

Changing the return type of thumbnail is technically a breaking change, however it has the same data structure as image (for now). Unless someone's bot is explicitly checking for the type hinted result this change is inconsequential.

valzargaming added a commit that referenced this pull request Sep 4, 2025
These will be updated again with #1396
@valzargaming valzargaming merged commit 7011572 into master Sep 4, 2025
1 of 2 checks passed
@valzargaming valzargaming deleted the embed-types branch September 4, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant