Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces event routing for interactions, including buttons and modals, within App Commands. It also refactors our terminology from "commands" to "applications" to more accurately reflect the functionality that can either handle events, commands, or both. Additionally, this PR includes crucial fixes and an example to facilitate understanding of the new features.
Key Changes
Feature Integration for Event-Driven Interactions: Implemented a framework to support interactions such as buttons and modals through event routing. This allows
app.OnEvent(...)
to be directly managed, offering a more intuitive handling of user interactions.Documentation and Examples: Added some documentation on utilising custom IDs for event handling, along with a practical example demonstrating the use of events and buttons. This aims to provide clear guidance on how to leverage the new functionalities effectively.
Application Type Flexibility: Introduced the ability for applications to be classified not just as commands but also as event-only applications, enhancing the versatility of our bot's operational capabilities.
Refactoring: Shifted the terminology from "commands" to "applications" to better encompass the dual nature of these functionalities, which can now be either event-driven, command-driven, or both.
Environment Configuration Fix: Corrected the sequence of loading environment variables to ensure that token variables are set post-loading the .env file, addressing a critical setup issue.
Library Update and Bug Fix: Updated the discordgo library to its latest version, which resolves a bug related to message component buttons. This fix permits the omission of emojis in message components, where previously an emoji was required, preventing potential errors.
Implementation Details
Events and interactions are now seamlessly integrated through the application type, with a routing mechanism for handling events
app.OnEvent(...)
.The use of
custom_id
in interactions follows a structured format, facilitating the parsing of commands and subcommands, and is accessible viactx.EventValue()
.Provided an illustrative example of a ping button, showcasing the practical application of the event system and demonstrating the ease of implementing interactive components.