mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-01 07:40:07 +00:00
[commands] Properly call after_hooks in hybrid commands
This commit is contained in:
parent
c1892131a6
commit
1232a1d2fd
@ -197,10 +197,9 @@ class HybridAppCommand(discord.app_commands.Command[CogT, P, T]):
|
|||||||
# If someone doesn't inherit this to replace it with their custom class
|
# If someone doesn't inherit this to replace it with their custom class
|
||||||
# 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
|
||||||
exc: CommandError
|
|
||||||
try:
|
try:
|
||||||
await self.wrapped.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
|
return await self._do_call(ctx, ctx.kwargs) # type: ignore
|
||||||
except app_commands.CommandSignatureMismatch:
|
except app_commands.CommandSignatureMismatch:
|
||||||
@ -211,13 +210,18 @@ class HybridAppCommand(discord.app_commands.Command[CogT, P, T]):
|
|||||||
else:
|
else:
|
||||||
exc = HybridCommandError(e)
|
exc = HybridCommandError(e)
|
||||||
exc.__cause__ = e
|
exc.__cause__ = e
|
||||||
|
await command.dispatch_error(ctx, exc)
|
||||||
except app_commands.AppCommandError as e:
|
except app_commands.AppCommandError as e:
|
||||||
exc = HybridCommandError(e)
|
exc = HybridCommandError(e)
|
||||||
exc.__cause__ = e
|
exc.__cause__ = e
|
||||||
|
await command.dispatch_error(ctx, exc)
|
||||||
except CommandError as e:
|
except CommandError as e:
|
||||||
exc = e
|
await command.dispatch_error(ctx, e)
|
||||||
|
finally:
|
||||||
|
if command._max_concurrency is not None:
|
||||||
|
await command._max_concurrency.release(ctx.message)
|
||||||
|
|
||||||
await self.wrapped.dispatch_error(ctx, exc)
|
await command.call_after_hooks(ctx)
|
||||||
|
|
||||||
|
|
||||||
class HybridCommand(Command[CogT, P, T]):
|
class HybridCommand(Command[CogT, P, T]):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user