Add on_app_command_completion event

Fix #8126
This commit is contained in:
Rapptz 2022-08-15 09:19:01 -04:00
parent 0b69148c84
commit 0ec06f0ac5
2 changed files with 16 additions and 0 deletions

View File

@ -1189,6 +1189,8 @@ class CommandTree(Generic[ClientT]):
if ctx_menu.on_error is not None:
await ctx_menu.on_error(interaction, e)
await self.on_error(interaction, e)
else:
self.client.dispatch('app_command_completion', interaction, ctx_menu)
async def interaction_check(self, interaction: Interaction, /) -> bool:
"""|coro|
@ -1237,3 +1239,5 @@ class CommandTree(Generic[ClientT]):
except AppCommandError as e:
await command._invoke_error_handlers(interaction, e)
await self.on_error(interaction, e)
else:
self.client.dispatch('app_command_completion', interaction, command)

View File

@ -215,6 +215,18 @@ App Commands
:param payload: The raw event payload data.
:type payload: :class:`RawAppCommandPermissionsUpdateEvent`
.. function:: on_app_command_completion(interaction, command)
Called when a :class:`app_commands.Command` or :class:`app_commands.ContextMenu` has
successfully completed without error.
.. versionadded:: 2.0
:param interaction: The interaction of the command.
:type interaction: :class:`Interaction`
:param command: The command that completed successfully
:type command: Union[:class:`app_commands.Command`, :class:`app_commands.ContextMenu`]
AutoMod
~~~~~~~~