Conversation
|
The documentation preview is available at https://preview.netcord.dev/296. |
There was a problem hiding this comment.
Pull request overview
This PR implements pre-execution handlers for all command/interaction handler types in NetCord.Hosting.Services, addressing issue #290 (pre and post-execution events). It introduces a PreExecutionResult discriminated union and corresponding handler interfaces/defaults, allowing users to intercept and optionally abort command/interaction execution.
Changes:
- New
PreExecutionResulthierarchy (ContinuePreExecutionResult,SkipPreExecutionResult) enabling return-type-driven flow control from pre-execution handlers. - Interfaces and default implementations for pre-execution handlers across all four handler types: application commands, autocomplete interactions, component interactions, and text commands.
- Integration of the pre-execution handlers into all four existing handler execution paths, including exception handling and early exit on
Skip.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
CommandPreExecutionResult.cs |
Defines the closed PreExecutionResult type hierarchy (Continue/Skip) |
ApplicationCommands/IApplicationCommandPreExecutionHandler.cs |
New interface for application command pre-execution |
ApplicationCommands/ApplicationCommandPreExecutionHandler.cs |
Default implementation: logs command name, returns Continue |
ApplicationCommands/IAutocompleteInteractionPreExecutionHandler.cs |
New interface for autocomplete pre-execution |
ApplicationCommands/AutocompleteInteractionPreExecutionHandler.cs |
Default implementation: logs autocomplete command name, returns Continue |
ApplicationCommands/ApplicationCommandServiceOptions.cs |
Adds PreExecutionHandler and AutocompletePreExecutionHandler options |
ApplicationCommands/ApplicationCommandInteractionHandler.cs |
Integrates pre-execution handler into the app command execution path |
ApplicationCommands/AutocompleteInteractionHandler.cs |
Integrates pre-execution handler into the autocomplete execution path |
Commands/ICommandPreExecutionHandler.cs |
New interface for text command pre-execution |
Commands/CommandPreExecutionHandler.cs |
Default implementation: logs message content, returns Continue |
Commands/CommandServiceOptions.cs |
Adds PreExecutionHandler option |
Commands/CommandHandler.cs |
Integrates pre-execution handler into the text command execution path |
ComponentInteractions/ICommandPreExecutionHandler.cs |
Misnamed file – contains IComponentInteractionPreExecutionHandler<TContext> (should be IComponentInteractionPreExecutionHandler.cs) |
ComponentInteractions/ComponentInteractionPreExecutionHandler.cs |
Default implementation: logs custom ID, returns Continue |
ComponentInteractions/ComponentInteractionServiceOptions.cs |
Adds PreExecutionHandler option |
ComponentInteractions/ComponentInteractionHandler.cs |
Integrates pre-execution handler into the component interaction execution path |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...g/NetCord.Hosting.Services/ComponentInteractions/IComponentInteractionPreExecutionHandler.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #290