Skip to content

Conversation

@valzargaming
Copy link
Member

This pull request refactors the handling of components in several builder classes by introducing a reusable trait, ComponentsTrait. The trait consolidates the logic for managing components, reducing code duplication and improving maintainability. The change affects multiple builder classes, which now use the trait instead of their own implementations of setComponents and addComponents.

Trait introduction and code deduplication

  • Added new ComponentsTrait in src/Discord/Builders/ComponentsTrait.php, encapsulating shared logic for setting and adding components, and requiring an addComponent method in the using class.
  • Refactored ActionRow, Container, Section, MessageBuilder, and ModalBuilder classes to use ComponentsTrait, removing their individual implementations of setComponents and addComponents. [1] [2] [3] [4] [5] [6] [7] [8]

Removal of redundant methods

  • Removed the now-redundant setComponents and addComponents methods from ActionRow, Container, Section, MessageBuilder, and ModalBuilder, as their functionality is replaced by the trait. [1] [2] [3] [4] [5]

These changes make the codebase cleaner and more maintainable by centralizing common component logic.

@valzargaming valzargaming requested a review from a team December 9, 2025 16:50
@valzargaming valzargaming merged commit 2591c46 into master Dec 12, 2025
2 checks passed
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.

2 participants