From 7efccbaf49edc538603410ce64038996fed4aebe Mon Sep 17 00:00:00 2001 From: BobDotCom Date: Mon, 30 Aug 2021 09:33:02 -0500 Subject: [PATCH] Command types in registration --- discord/bot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/discord/bot.py b/discord/bot.py index 2eb990b53d..9a9765a250 100644 --- a/discord/bot.py +++ b/discord/bot.py @@ -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"] @@ -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 @@ -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