mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-10 15:59:50 +00:00
[commands] Only call hybrid after_invoke hooks if the command is called
Fix #8276
This commit is contained in:
parent
dc8cbc073e
commit
c43d302a28
@ -419,10 +419,12 @@ class HybridAppCommand(discord.app_commands.Command[CogT, P, T]):
|
||||
command = self.wrapped
|
||||
bot.dispatch('command', ctx)
|
||||
value = None
|
||||
callback_completed = False
|
||||
try:
|
||||
await command.prepare(ctx)
|
||||
# This lies and just always passes a Context instead of an Interaction.
|
||||
value = await self._do_call(ctx, ctx.kwargs) # type: ignore
|
||||
callback_completed = True
|
||||
except app_commands.CommandSignatureMismatch:
|
||||
raise
|
||||
except (app_commands.TransformerError, app_commands.CommandInvokeError) as e:
|
||||
@ -442,7 +444,8 @@ class HybridAppCommand(discord.app_commands.Command[CogT, P, T]):
|
||||
if command._max_concurrency is not None:
|
||||
await command._max_concurrency.release(ctx.message)
|
||||
|
||||
await command.call_after_hooks(ctx)
|
||||
if callback_completed:
|
||||
await command.call_after_hooks(ctx)
|
||||
|
||||
if not ctx.command_failed:
|
||||
bot.dispatch('command_completion', ctx)
|
||||
|
Loading…
x
Reference in New Issue
Block a user