Skip to content

Commit d0c2074

Browse files
committed
temporary fix for errors in register_commands
1 parent 2f6d221 commit d0c2074

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

discord/bot.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,25 @@ async def register_commands(self) -> None:
191191
to_update = update_guild_commands[guild_id]
192192
update_guild_commands[guild_id] = to_update + [as_dict]
193193

194+
raised_error = None
195+
raised_guilds = []
194196
for guild_id in update_guild_commands:
195197
try:
196198
cmds = await self.http.bulk_upsert_guild_commands(self.user.id, guild_id,
197199
update_guild_commands[guild_id])
198-
except Forbidden:
199-
print(f'Ignoring exception running bulk_upsert_guild_commands on guild {guild_id}', file=sys.stderr)
200-
traceback.print_exc()
200+
except Forbidden as e:
201+
raised_error = e
202+
raised_guilds.append(guild_id)
201203
for i in cmds:
202204
cmd = get(self.to_register, name=i["name"], description=i["description"], type=i['type'])
203205
self.app_commands[i["id"]] = cmd
206+
if raised_error:
207+
try:
208+
raise raised_error
209+
except Forbidden:
210+
print(f'Ignoring exception running bulk_upsert_guild_commands on guilds {raised_guilds}',
211+
file=sys.stderr)
212+
traceback.print_exc()
204213

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

0 commit comments

Comments
 (0)