From 82bb3e403f4c1a00389c60fc268ba015de400592 Mon Sep 17 00:00:00 2001 From: Quin Lynch <49576606+quinchs@users.noreply.github.com> Date: Fri, 24 Dec 2021 10:38:33 -0400 Subject: [PATCH] Fix CommandExecuted not invoked on failed parse (#1993) Co-Authored-By: Adam Gauthier <16079556+louistio@users.noreply.github.com> --- src/Discord.Net.Commands/CommandService.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index e2bfeeb44..fce67b9b2 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -541,6 +541,12 @@ namespace Discord.Commands if (matchResult.Pipeline is ParseResult parseResult) { + if (!parseResult.IsSuccess) + { + await _commandExecutedEvent.InvokeAsync(matchResult.Match.Value.Command, context, parseResult); + return parseResult; + } + var executeResult = await matchResult.Match.Value.ExecuteAsync(context, parseResult, services); if (!executeResult.IsSuccess && !(executeResult is RuntimeResult || executeResult is ExecuteResult)) // succesful results raise the event in CommandInfo#ExecuteInternalAsync (have to raise it there b/c deffered execution)