Skip to content

Commit

Permalink
chore: simplify ambiguity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
EQUENOS committed Sep 24, 2023
1 parent c44806b commit ef591e6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions disnake/ext/commands/interaction_bot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,8 @@ def get_slash_command(
continue
if result is None:
result = chain_match
continue
# we should check whether there's an ambiguity in command search
result_guild_ids = (result.root_parent or result).guild_ids
match_guild_ids = (chain_match.root_parent or chain_match).guild_ids
if result_guild_ids != match_guild_ids:
elif chain_match is not result:
raise ValueError(
"Argument guild_id must be provided if there're different slash commands "
"with the same name but different guilds or one of them is global."
Expand Down Expand Up @@ -656,7 +653,7 @@ def get_user_command(
if result is None:
result = command
# we should check whether there's an ambiguity in command search
elif result.guild_ids != command.guild_ids:
elif command is not result:
raise ValueError(
"Argument guild_id must be provided if there're different user commands "
"with the same name but different guilds or one of them is global."
Expand Down Expand Up @@ -705,7 +702,7 @@ def get_message_command(
if result is None:
result = command
# we should check whether there's an ambiguity in command search
elif result.guild_ids != command.guild_ids:
elif command is not result:
raise ValueError(
"Argument guild_id must be provided if there're different message commands "
"with the same name but different guilds or one of them is global."
Expand Down

0 comments on commit ef591e6

Please sign in to comment.