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:
|
async def _dispatch_error(self, interaction: Interaction, error: AppCommandError, /) -> None:
|
||||||
command = interaction.command
|
command = interaction.command
|
||||||
|
interaction.command_failed = True
|
||||||
if isinstance(command, Command):
|
if isinstance(command, Command):
|
||||||
await command._invoke_error_handlers(interaction, error)
|
await command._invoke_error_handlers(interaction, error)
|
||||||
else:
|
else:
|
||||||
@ -1205,6 +1206,7 @@ class CommandTree(Generic[ClientT]):
|
|||||||
|
|
||||||
async def _call(self, interaction: Interaction) -> None:
|
async def _call(self, interaction: Interaction) -> None:
|
||||||
if not await self.interaction_check(interaction):
|
if not await self.interaction_check(interaction):
|
||||||
|
interaction.command_failed = True
|
||||||
return
|
return
|
||||||
|
|
||||||
data: ApplicationCommandInteractionData = interaction.data # type: ignore
|
data: ApplicationCommandInteractionData = interaction.data # type: ignore
|
||||||
@ -1237,7 +1239,9 @@ class CommandTree(Generic[ClientT]):
|
|||||||
try:
|
try:
|
||||||
await command._invoke_with_namespace(interaction, namespace)
|
await command._invoke_with_namespace(interaction, namespace)
|
||||||
except AppCommandError as e:
|
except AppCommandError as e:
|
||||||
|
interaction.command_failed = True
|
||||||
await command._invoke_error_handlers(interaction, e)
|
await command._invoke_error_handlers(interaction, e)
|
||||||
await self.on_error(interaction, e)
|
await self.on_error(interaction, e)
|
||||||
else:
|
else:
|
||||||
self.client.dispatch('app_command_completion', interaction, command)
|
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:
|
if not ctx.command_failed:
|
||||||
bot.dispatch('command_completion', ctx)
|
bot.dispatch('command_completion', ctx)
|
||||||
|
|
||||||
|
interaction.command_failed = ctx.command_failed
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,6 +116,9 @@ class Interaction:
|
|||||||
A dictionary that can be used to store extraneous data for use during
|
A dictionary that can be used to store extraneous data for use during
|
||||||
interaction processing. The library will not touch any values or keys
|
interaction processing. The library will not touch any values or keys
|
||||||
within this dictionary.
|
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, ...] = (
|
__slots__: Tuple[str, ...] = (
|
||||||
@ -132,6 +135,7 @@ class Interaction:
|
|||||||
'locale',
|
'locale',
|
||||||
'guild_locale',
|
'guild_locale',
|
||||||
'extras',
|
'extras',
|
||||||
|
'command_failed',
|
||||||
'_permissions',
|
'_permissions',
|
||||||
'_app_permissions',
|
'_app_permissions',
|
||||||
'_state',
|
'_state',
|
||||||
@ -155,6 +159,7 @@ class Interaction:
|
|||||||
# an interaction. This is mainly for internal purposes and it gives it a free-for-all slot.
|
# an interaction. This is mainly for internal purposes and it gives it a free-for-all slot.
|
||||||
self._baton: Any = MISSING
|
self._baton: Any = MISSING
|
||||||
self.extras: Dict[Any, Any] = {}
|
self.extras: Dict[Any, Any] = {}
|
||||||
|
self.command_failed: bool = False
|
||||||
self._from_data(data)
|
self._from_data(data)
|
||||||
|
|
||||||
def _from_data(self, data: InteractionPayload):
|
def _from_data(self, data: InteractionPayload):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user