Skip to content

Commit

Permalink
Command types in registration
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDotCom committed Aug 30, 2021
1 parent 8846ee5 commit 7efccba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def register_commands(self):
for command in [cmd for cmd in self.to_register if cmd.guild_ids is None]:
as_dict = command.to_dict()
if not len(registered_commands) == 0:
matches = [x for x in registered_commands if x["name"] == command.name]
matches = [x for x in registered_commands if x["name"] == command.name and x['type'] == command.type]
# TODO: rewrite this, it seems inefficient
if len(matches) > 0:
as_dict['id'] = matches[0]["id"]
Expand All @@ -92,7 +92,7 @@ async def register_commands(self):
for guild_id in command.guild_ids:
fetched = fetched_guild_commands.get(guild_id)
to_update = update_guild_commands.get(guild_id, [])
matches = [x for x in fetched if x["name"] == command.name]
matches = [x for x in fetched if x["name"] == command.name and x['type'] == command.type]
if len(matches) > 0:
as_dict['id'] = matches[0]["id"]
elif as_dict.get('id'): # matched in another guild but not this one
Expand All @@ -102,14 +102,14 @@ async def register_commands(self):
for guild_id in update_guild_commands:
cmds = await self.http.bulk_upsert_guild_commands(self.user.id, guild_id, update_guild_commands[guild_id])
for i in cmds:
cmd = get(self.to_register, name=i["name"], description=i["description"], type=1)
cmd = get(self.to_register, name=i["name"], description=i["description"], type=i['type'])
self.app_commands[i["id"]] = cmd

cmds = await self.http.bulk_upsert_global_commands(self.user.id, commands)

for i in cmds:
cmd = get(
self.to_register, name=i["name"], description=i["description"], type=1
self.to_register, name=i["name"], description=i["description"], type=i['type']
)
self.app_commands[i["id"]] = cmd

Expand Down

0 comments on commit 7efccba

Please sign in to comment.