From a6ae7ec1965f650934ab2e236e7237ebe0036c77 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 9 Mar 2022 20:35:07 -0500 Subject: [PATCH] Raise error if two trees are registered to the same connection state --- discord/app_commands/tree.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/discord/app_commands/tree.py b/discord/app_commands/tree.py index be16b0c3e..f56687296 100644 --- a/discord/app_commands/tree.py +++ b/discord/app_commands/tree.py @@ -93,6 +93,10 @@ class CommandTree(Generic[ClientT]): self.client: ClientT = client self._http = client.http self._state = client._connection + + if self._state._command_tree is not None: + raise ClientException('This client already has an associated command tree.') + self._state._command_tree = self self._guild_commands: Dict[int, Dict[str, Union[Command, Group]]] = {} self._global_commands: Dict[str, Union[Command, Group]] = {}