Skip to content

Commit

Permalink
Fix AttributeError in CommandSyncFailure due to APPLICATION_COMMAND_T…
Browse files Browse the repository at this point in the history
…OO_LARGE
  • Loading branch information
Rapptz committed Sep 27, 2023
1 parent 48b4ea8 commit 576ab26
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions discord/app_commands/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,18 @@ def __init__(self, child: HTTPException, commands: List[CommandTypes]) -> None:
messages = [f'Failed to upload commands to Discord (HTTP status {self.status}, error code {self.code})']

if self._errors:
for index, inner in self._errors.items():
_get_command_error(index, inner, commands, messages)
# Handle case where the errors dict has no actual chain such as APPLICATION_COMMAND_TOO_LARGE
if len(self._errors) == 1 and '_errors' in self._errors:
errors = self._errors['_errors']
if len(errors) == 1:
extra = errors[0].get('message')
if extra:
messages[0] += f': {extra}'
else:
messages.extend(f'Error {e.get("code", "")}: {e.get("message", "")}' for e in errors)
else:
for index, inner in self._errors.items():
_get_command_error(index, inner, commands, messages)

# Equivalent to super().__init__(...) but skips other constructors
self.args = ('\n'.join(messages),)

1 comment on commit 576ab26

@alinub
Copy link

@alinub alinub commented on 576ab26 Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

Please sign in to comment.