Browse Source

Or just remove "is not None"

pull/10216/head
Soheab_ 4 weeks ago
parent
commit
ce231ca6f7
  1. 14
      discord/app_commands/models.py

14
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 {}) self.description_localizations: Dict[Locale, str] = _to_locale_dict(data.get('description_localizations') or {})
def to_dict(self) -> ApplicationCommandPayload: def to_dict(self) -> ApplicationCommandPayload:
res = { return {
'id': self.id, 'id': self.id,
'type': self.type.value, 'type': self.type.value,
'application_id': self.application_id, 'application_id': self.application_id,
@ -254,16 +254,10 @@ class AppCommand(Hashable):
'description': self.description, 'description': self.description,
'name_localizations': {str(k): v for k, v in self.name_localizations.items()}, '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()}, '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], 'options': [opt.to_dict() for opt in self.options],
} } # type: ignore # Type checker does not understand this literal.
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.
def __str__(self) -> str: def __str__(self) -> str:
return self.name return self.name

Loading…
Cancel
Save