mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Fix app_command_completion triggering on certain errors
This commit is contained in:
parent
7be0779b65
commit
bd19ad05e7
@ -1077,6 +1077,7 @@ class CommandTree(Generic[ClientT]):
|
||||
|
||||
async def _dispatch_error(self, interaction: Interaction, error: AppCommandError, /) -> None:
|
||||
command = interaction.command
|
||||
interaction.command_failed = True
|
||||
if isinstance(command, Command):
|
||||
await command._invoke_error_handlers(interaction, error)
|
||||
else:
|
||||
@ -1205,6 +1206,7 @@ class CommandTree(Generic[ClientT]):
|
||||
|
||||
async def _call(self, interaction: Interaction) -> None:
|
||||
if not await self.interaction_check(interaction):
|
||||
interaction.command_failed = True
|
||||
return
|
||||
|
||||
data: ApplicationCommandInteractionData = interaction.data # type: ignore
|
||||
@ -1237,7 +1239,9 @@ class CommandTree(Generic[ClientT]):
|
||||
try:
|
||||
await command._invoke_with_namespace(interaction, namespace)
|
||||
except AppCommandError as e:
|
||||
interaction.command_failed = True
|
||||
await command._invoke_error_handlers(interaction, e)
|
||||
await self.on_error(interaction, e)
|
||||
else:
|
||||
if not interaction.command_failed:
|
||||
self.client.dispatch('app_command_completion', interaction, command)
|
||||
|
@ -462,6 +462,7 @@ class HybridAppCommand(discord.app_commands.Command[CogT, P, T]):
|
||||
if not ctx.command_failed:
|
||||
bot.dispatch('command_completion', ctx)
|
||||
|
||||
interaction.command_failed = ctx.command_failed
|
||||
return value
|
||||
|
||||
|
||||
|
@ -116,6 +116,9 @@ class Interaction:
|
||||
A dictionary that can be used to store extraneous data for use during
|
||||
interaction processing. The library will not touch any values or keys
|
||||
within this dictionary.
|
||||
command_failed: :class:`bool`
|
||||
Whether the command associated with this interaction failed to execute.
|
||||
This includes checks and execution.
|
||||
"""
|
||||
|
||||
__slots__: Tuple[str, ...] = (
|
||||
@ -132,6 +135,7 @@ class Interaction:
|
||||
'locale',
|
||||
'guild_locale',
|
||||
'extras',
|
||||
'command_failed',
|
||||
'_permissions',
|
||||
'_app_permissions',
|
||||
'_state',
|
||||
@ -155,6 +159,7 @@ class Interaction:
|
||||
# an interaction. This is mainly for internal purposes and it gives it a free-for-all slot.
|
||||
self._baton: Any = MISSING
|
||||
self.extras: Dict[Any, Any] = {}
|
||||
self.command_failed: bool = False
|
||||
self._from_data(data)
|
||||
|
||||
def _from_data(self, data: InteractionPayload):
|
||||
|
Loading…
x
Reference in New Issue
Block a user