From 886d226641e3b9c05b64e6f2a999a3baf4abfd57 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Sun, 18 Aug 2024 23:27:41 +0200 Subject: [PATCH] Combine ContextMenu if-statement --- discord/app_commands/tree.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/discord/app_commands/tree.py b/discord/app_commands/tree.py index ef77b63f3..d41e8b95b 100644 --- a/discord/app_commands/tree.py +++ b/discord/app_commands/tree.py @@ -276,10 +276,9 @@ class CommandTree(Generic[ClientT]): if isinstance(command, AppCommand): return command.id - elif isinstance(command, (Command, Group)): - name = (command.root_parent or command).name - elif isinstance(command, ContextMenu): - name = command.name + + if isinstance(command, (Command, Group, ContextMenu)): + name = (command.root_parent or command).name if not isinstance(command, ContextMenu) else command.name elif isinstance(command, str): name = command.split()[0] @@ -311,10 +310,8 @@ class CommandTree(Generic[ClientT]): if command_id is None: return None - if isinstance(command, (Command, Group)): + if isinstance(command, (Command, Group, ContextMenu)): full_name = command.qualified_name - elif isinstance(command, ContextMenu): - full_name = command.name elif isinstance(command, str): full_name = command