Skip to content

Commit 14c361c

Browse files
committed
Handle command registration errors better
1 parent 9ad0f67 commit 14c361c

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

discord/bot.py

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

2727
from typing import Callable, Optional
2828

29-
import traceback
30-
import sys
31-
3229
from .client import Client
3330
from .shard import AutoShardedClient
3431
from .utils import get
@@ -192,8 +189,6 @@ async def register_commands(self) -> None:
192189
to_update = update_guild_commands[guild_id]
193190
update_guild_commands[guild_id] = to_update + [as_dict]
194191

195-
raised_error = None
196-
raised_guilds = []
197192
for guild_id in update_guild_commands:
198193
try:
199194
cmds = await self.http.bulk_upsert_guild_commands(self.user.id, guild_id,
@@ -202,11 +197,10 @@ async def register_commands(self) -> None:
202197
cmd = get(self.to_register, name=i["name"], description=i["description"], type=i['type'])
203198
self.app_commands[i["id"]] = cmd
204199
except Forbidden:
205-
raised_error = raised_error or traceback.format_exc()
206-
raised_guilds.append(guild_id)
207-
if raised_error:
208-
print(f'Ignoring exception running bulk_upsert_guild_commands on guilds {raised_guilds}', file=sys.stderr)
209-
print(raised_error, file=sys.stderr)
200+
if update_guild_commands[guild_id]:
201+
continue
202+
else:
203+
raise
210204

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

0 commit comments

Comments
 (0)