Skip to content

Commit 4211ecc

Browse files
committed
fix error handler inside register_commands
1 parent 28b3f81 commit 4211ecc

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

discord/bot.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,12 @@ async def register_commands(self) -> None:
200200
for i in cmds:
201201
cmd = get(self.to_register, name=i["name"], description=i["description"], type=i['type'])
202202
self.app_commands[i["id"]] = cmd
203-
except Forbidden as e:
204-
raised_error = e
203+
except Forbidden:
204+
raised_error = raised_error or traceback.format_exc()
205205
raised_guilds.append(guild_id)
206206
if raised_error:
207-
try: # TODO: this is awful
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()
207+
print(f'Ignoring exception running bulk_upsert_guild_commands on guilds {raised_guilds}', file=sys.stderr)
208+
print(raised_error, file=sys.stderr)
213209

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

0 commit comments

Comments
 (0)