The current lifecycle events for commands are on_command (fires before execution) and on_command_error (fires on failure). There is no hook for successful completion, making it impossible to cleanly implement concerns like audit logging, metrics, or post-command cleanup without patching into after_invoke on every individual command.
Adding on_command_completion to LIFECYCLE_EVENTS fills that gap. It would fire after a command finishes without raising an exception, receiving the same Context object as on_command.
Proposed API
@bot.hook
async def on_command_completion(ctx):
print(f"{ctx.command} completed successfully for {ctx.sender}")
The current lifecycle events for commands are
on_command(fires before execution) andon_command_error(fires on failure). There is no hook for successful completion, making it impossible to cleanly implement concerns like audit logging, metrics, or post-command cleanup without patching intoafter_invokeon every individual command.Adding
on_command_completiontoLIFECYCLE_EVENTSfills that gap. It would fire after a command finishes without raising an exception, receiving the sameContextobject ason_command.Proposed API