Skip to content

Conversation

valzargaming
Copy link
Member

This pull request introduces a refactor to how Discord interaction events are handled, making the system more extensible and type-safe. The main change is the introduction of dedicated classes for each interaction type, enabling more precise handling and easier future maintenance. Additionally, a new method is added to the channel select component to indicate if a field is required.

Interaction handling refactor

  • Added dedicated classes for each interaction type: Ping, ApplicationCommand, MessageComponent, ApplicationCommandAutocomplete, and ModalSubmit, each with their own type constants and data attribute handling. [1] [2] [3] [4] [5]
  • Introduced the TYPES constant in Interaction.php to map interaction type integers to their respective classes for dynamic instantiation.
  • Updated the event handler in InteractionCreate.php to instantiate the correct interaction class based on the type using the new TYPES mapping.

Component improvements

  • Added a setRequired method to ChannelSelect.php to allow specifying if a component is required (for modals).

@valzargaming valzargaming merged commit c07849e into master Aug 24, 2025
1 check passed
@valzargaming valzargaming deleted the interaction-classes branch August 24, 2025 04:40
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