Skip to content

Commit

Permalink
Convert interaction.data["guild_id"] to int in the KeyError fallback …
Browse files Browse the repository at this point in the history
…within process_application_commands (#1262)

* Convert interaction.data["guild_id"] to int

Fixes the KeyError fallback; before this fix, this expression would always return False.

* Update discord/bot.py

Co-authored-by: krittick <[email protected]>
  • Loading branch information
NeloBlivion and krittick authored Apr 17, 2022
1 parent 646df61 commit ea69bf5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,9 +812,12 @@ async def process_application_commands(self, interaction: Interaction, auto_sync
command = self._application_commands[interaction.data["id"]]
except KeyError:
for cmd in self.application_commands:
guild_id = interaction.data.get("guild_id")
if guild_id:
guild_id = int(guild_id)
if cmd.name == interaction.data["name"] and (
interaction.data.get("guild_id") == cmd.guild_ids
or (isinstance(cmd.guild_ids, list) and interaction.data.get("guild_id") in cmd.guild_ids)
guild_id == cmd.guild_ids
or (isinstance(cmd.guild_ids, list) and guild_id in cmd.guild_ids)
):
command = cmd
break
Expand Down

0 comments on commit ea69bf5

Please sign in to comment.