Skip to content

Commit

Permalink
fix: invoke CommandExecuted on async exception failures
Browse files Browse the repository at this point in the history
  • Loading branch information
foxbot committed Oct 20, 2018
1 parent a253b7e commit 6260749
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Discord.Net.Commands/Info/CommandInfo.cs
Expand Up @@ -272,6 +272,10 @@ private async Task<IResult> ExecuteInternalAsync(ICommandContext context, object

var wrappedEx = new CommandException(this, context, ex);
await Module.Service._cmdLogger.ErrorAsync(wrappedEx).ConfigureAwait(false);

var result = ExecuteResult.FromError(CommandError.Exception, ex.Message);
await Module.Service._commandExecutedEvent.InvokeAsync(this, context, result).ConfigureAwait(false);

if (Module.Service._throwOnError)
{
if (ex == originalEx)
Expand All @@ -280,7 +284,7 @@ private async Task<IResult> ExecuteInternalAsync(ICommandContext context, object
ExceptionDispatchInfo.Capture(ex).Throw();
}

return ExecuteResult.FromError(CommandError.Exception, ex.Message);
return result;
}
finally
{
Expand Down

0 comments on commit 6260749

Please sign in to comment.