Skip to content

Conversation

@valzargaming
Copy link

@valzargaming valzargaming commented Dec 12, 2025

This pull request refactors how the Discord instance is accessed throughout the bot's application command logic, introduces a create method for building Discord command objects, and moves the usage property to a more appropriate location. The main themes are code consistency, improved command construction, and minor cleanup.

Refactoring Discord Instance Access:

  • Replaces direct property access ($this->discord) with a method call ($this->discord()) throughout the HasApplicationCommands concern and related command classes to standardize and encapsulate how the Discord instance is retrieved. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Command Construction Improvements:

  • Adds a create method to the ApplicationCommand class for building Discord command objects using CommandBuilder, ensuring consistent construction and serialization of commands.
  • Updates command serialization to use jsonSerialize() instead of toArray() for compatibility and accuracy in both HasApplicationCommands and SlashCommand. [1] [2]

Code Organization and Cleanup:

  • Moves the usage property from the Command class to the more general AbstractCommand class, ensuring all commands can define usage information. [1] [2]
  • Adds a docblock to the HasApplicationCommands trait for clarity and documentation.

Dependency Imports:

  • Adds missing imports for Discord\Discord, CommandBuilder, and Command where necessary for type safety and clarity. [1] [2]

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