diff --git a/discord/app_commands/tree.py b/discord/app_commands/tree.py index c8e2134ef..3a24a9230 100644 --- a/discord/app_commands/tree.py +++ b/discord/app_commands/tree.py @@ -1075,7 +1075,7 @@ class CommandTree(Generic[ClientT]): def _from_interaction(self, interaction: Interaction) -> None: async def wrapper(): try: - await self.call(interaction) + await self._call(interaction) except AppCommandError as e: await self._dispatch_error(interaction, e) @@ -1191,29 +1191,7 @@ class CommandTree(Generic[ClientT]): """ return True - async def call(self, interaction: Interaction) -> None: - """|coro| - - Given an :class:`~discord.Interaction`, calls the matching - application command that's being invoked. - - This is usually called automatically by the library. - - Parameters - ----------- - interaction: :class:`~discord.Interaction` - The interaction to dispatch from. - - Raises - -------- - CommandNotFound - The application command referred to could not be found. - CommandSignatureMismatch - The interaction data referred to a parameter that was not found in the - application command definition. - AppCommandError - An error occurred while calling the command. - """ + async def _call(self, interaction: Interaction) -> None: if not await self.interaction_check(interaction): return diff --git a/tests/test_app_commands_invoke.py b/tests/test_app_commands_invoke.py index 38ead3e56..35915c19b 100644 --- a/tests/test_app_commands_invoke.py +++ b/tests/test_app_commands_invoke.py @@ -100,9 +100,9 @@ client = discord.Client(intents=discord.Intents.default()) class MockTree(discord.app_commands.CommandTree): last_exception: Optional[discord.app_commands.AppCommandError] - async def call(self, interaction: discord.Interaction) -> None: + async def _call(self, interaction: discord.Interaction) -> None: self.last_exception = None - return await super().call(interaction) + return await super()._call(interaction) async def on_error(self, interaction: discord.Interaction, error: discord.app_commands.AppCommandError) -> None: self.last_exception = error @@ -167,7 +167,7 @@ async def test_valid_command_invoke( command: discord.app_commands.Command[Any, ..., Any], raises: Optional[Type[BaseException]] ): interaction = MockCommandInteraction(client, command, foo='foo') - await tree.call(interaction) + await tree._call(interaction) if raises is None: assert tree.last_exception is None @@ -192,6 +192,6 @@ async def test_valid_command_invoke( @pytest.mark.asyncio async def test_invalid_command_invoke(command: discord.app_commands.Command[Any, ..., Any]): interaction = MockCommandInteraction(client, command, bar='bar') - await tree.call(interaction) + await tree._call(interaction) assert isinstance(tree.last_exception, discord.app_commands.CommandSignatureMismatch)