Rework CommandService#ExecuteAsync
logic and allow easier extensibility.
#1699
Labels
Needs investigation
Needs to be looked at by a maintainer
In the current state,
ExecuteAsync
does two functions. Command Execution andCommand Validation (Valid command check/ predicate check/ parameter check/ override check, etc.)
.My idea is to split those into two separate functions, one responsible for validating the commands and another for execution.
For compatibility and no major breaks, i decided to keep the current public api unchanged with only the addition of a
ValidateAndGetBestMatch
function with the following signature.This function is to be called with
Search(String)
's output makingExecuteAsync
's logic exclusive for execution,Search
's exclusive for searching andValidate...
exclusive for validation and command matching.An intended side-effect is the extensibility this would allow if accepted. An external CommandService wrapper could leverage Discord.Net's
Validate...
in order to get the command that best fits without executing it, as the only current way of getting the command that was called is via an event handler, but there is no clean way for getting a command that will be called.Status
siscodeorg/Discord.Net
The text was updated successfully, but these errors were encountered: