Browse Source

Fix AttributeError in CommandSyncFailure due to APPLICATION_COMMAND_TOO_LARGE

pull/9581/head
Rapptz 2 years ago
parent
commit
576ab269e8
  1. 14
      discord/app_commands/errors.py

14
discord/app_commands/errors.py

@ -530,8 +530,18 @@ class CommandSyncFailure(AppCommandError, HTTPException):
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),)

Loading…
Cancel
Save