Skip to content

Commit

Permalink
Updated to run in same for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
NeloBlivion committed Oct 16, 2022
1 parent af8a2f4 commit 8da66f7
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions discord/bot.py
Expand Up @@ -206,22 +206,20 @@ def get_application_command(
if guild_ids is not None and command.guild_ids != guild_ids:
return
return command

# If a top-level command was not found, attempt to search by qualified command name
if name.lower() == name and 1 < len(names := name.split()) <= 3 and all(names):
while len(names) > 1:
command = get(commands, name=names.pop(0))
if not isinstance(command, SlashCommandGroup):
return
if guild_ids is not None and command.guild_ids != guild_ids:
elif (names := name.split())[0] == command.name and isinstance(command, SlashCommandGroup):
while len(names) > 1:
command = get(commands, name=names.pop(0))
if not isinstance(command, SlashCommandGroup) or (
guild_ids is not None and command.guild_ids != guild_ids
):
return
commands = command.subcommands
command = get(commands, name=names.pop())
if not isinstance(command, type) or (
guild_ids is not None and command.guild_ids != guild_ids
):
return
commands = command.subcommands
command = get(commands, name=names.pop())
if not isinstance(command, type) or (
guild_ids is not None and command.guild_ids != guild_ids
):
return
return command
return command

async def get_desynced_commands(
self,
Expand Down

0 comments on commit 8da66f7

Please sign in to comment.