mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-18 23:15:48 +00:00
[commands] Dispatch command events for hybrid commands
This commit is contained in:
parent
7d2e5be3a1
commit
6113f856b6
@ -316,10 +316,12 @@ class HybridAppCommand(discord.app_commands.Command[CogT, P, T]):
|
|||||||
# then this doesn't work.
|
# then this doesn't work.
|
||||||
interaction._baton = ctx = await bot.get_context(interaction)
|
interaction._baton = ctx = await bot.get_context(interaction)
|
||||||
command = self.wrapped
|
command = self.wrapped
|
||||||
|
bot.dispatch('command', ctx)
|
||||||
|
value = None
|
||||||
try:
|
try:
|
||||||
await command.prepare(ctx)
|
await command.prepare(ctx)
|
||||||
# This lies and just always passes a Context instead of an Interaction.
|
# This lies and just always passes a Context instead of an Interaction.
|
||||||
return await self._do_call(ctx, ctx.kwargs) # type: ignore
|
value = await self._do_call(ctx, ctx.kwargs) # type: ignore
|
||||||
except app_commands.CommandSignatureMismatch:
|
except app_commands.CommandSignatureMismatch:
|
||||||
raise
|
raise
|
||||||
except (app_commands.TransformerError, app_commands.CommandInvokeError) as e:
|
except (app_commands.TransformerError, app_commands.CommandInvokeError) as e:
|
||||||
@ -341,6 +343,11 @@ class HybridAppCommand(discord.app_commands.Command[CogT, P, T]):
|
|||||||
|
|
||||||
await command.call_after_hooks(ctx)
|
await command.call_after_hooks(ctx)
|
||||||
|
|
||||||
|
if not ctx.command_failed:
|
||||||
|
bot.dispatch('command_completion', ctx)
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
class HybridCommand(Command[CogT, P, T]):
|
class HybridCommand(Command[CogT, P, T]):
|
||||||
r"""A class that is both an application command and a regular text command.
|
r"""A class that is both an application command and a regular text command.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user