From ce231ca6f7821753ca364092bda83169173ec157 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Wed, 25 Jun 2025 17:40:08 +0200 Subject: [PATCH] Or just remove "is not None" --- discord/app_commands/models.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/discord/app_commands/models.py b/discord/app_commands/models.py index 0d77559a4..1b2b26145 100644 --- a/discord/app_commands/models.py +++ b/discord/app_commands/models.py @@ -246,7 +246,7 @@ class AppCommand(Hashable): self.description_localizations: Dict[Locale, str] = _to_locale_dict(data.get('description_localizations') or {}) def to_dict(self) -> ApplicationCommandPayload: - res = { + return { 'id': self.id, 'type': self.type.value, 'application_id': self.application_id, @@ -254,16 +254,10 @@ class AppCommand(Hashable): 'description': self.description, 'name_localizations': {str(k): v for k, v in self.name_localizations.items()}, 'description_localizations': {str(k): v for k, v in self.description_localizations.items()}, + 'contexts': self.allowed_contexts.to_array() if self.allowed_contexts else None, + 'integration_types': self.allowed_installs.to_array() if self.allowed_installs else None, 'options': [opt.to_dict() for opt in self.options], - } - contexts = self.allowed_contexts.to_array() if self.allowed_contexts is not None else None - integration_types = self.allowed_installs.to_array() if self.allowed_installs is not None else None - if contexts: - res['contexts'] = contexts - if integration_types: - res['integration_types'] = integration_types - - return res # type: ignore # Type checker does not understand this literal. + } # type: ignore # Type checker does not understand this literal. def __str__(self) -> str: return self.name