Skip to content

Commit 2f6d221

Browse files
committed
catch errors with traceback.print_exc in register_commands
1 parent 7e4dcfd commit 2f6d221

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

discord/bot.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
from typing import Callable, Optional
2828

29+
import traceback
30+
import sys
31+
2932
from .client import Client
3033
from .shard import AutoShardedClient
3134
from .utils import get
@@ -189,8 +192,12 @@ async def register_commands(self) -> None:
189192
update_guild_commands[guild_id] = to_update + [as_dict]
190193

191194
for guild_id in update_guild_commands:
192-
cmds = await self.http.bulk_upsert_guild_commands(self.user.id, guild_id,
193-
update_guild_commands[guild_id])
195+
try:
196+
cmds = await self.http.bulk_upsert_guild_commands(self.user.id, guild_id,
197+
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()
194201
for i in cmds:
195202
cmd = get(self.to_register, name=i["name"], description=i["description"], type=i['type'])
196203
self.app_commands[i["id"]] = cmd

0 commit comments

Comments
 (0)