Browse Source

Update application asset paths and remove nonexistant Application.splash

pull/10109/head
dolfies 2 years ago
parent
commit
1cb06134b6
  1. 12
      discord/appinfo.py
  2. 31
      discord/asset.py

12
discord/appinfo.py

@ -1740,7 +1740,6 @@ class PartialApplication(Hashable):
self._icon: Optional[str] = data.get('icon')
self._cover_image: Optional[str] = data.get('cover_image')
self._splash: Optional[str] = data.get('splash')
self.terms_of_service_url: Optional[str] = data.get('terms_of_service_url')
self.privacy_policy_url: Optional[str] = data.get('privacy_policy_url')
@ -1819,14 +1818,7 @@ class PartialApplication(Hashable):
"""Optional[:class:`Asset`]: Retrieves the application's cover image, if any."""
if self._cover_image is None:
return None
return Asset._from_cover_image(self._state, self.id, self._cover_image)
@property
def splash(self) -> Optional[Asset]:
"""Optional[:class:`Asset`]: Retrieves the application's splash asset, if any."""
if self._splash is None:
return None
return Asset._from_application_asset(self._state, self.id, self._splash)
return Asset._from_icon(self._state, self.id, self._cover_image, path='app')
@property
def flags(self) -> ApplicationFlags:
@ -3356,7 +3348,7 @@ class IntegrationApplication(Hashable):
"""Optional[:class:`Asset`]: Retrieves the application's cover image, if any."""
if self._cover_image is None:
return None
return Asset._from_cover_image(self._state, self.id, self._cover_image)
return Asset._from_icon(self._state, self.id, self._cover_image, path='app')
@property
def primary_sku_url(self) -> Optional[str]:

31
discord/asset.py

@ -264,15 +264,6 @@ class Asset(AssetMixin):
animated=False,
)
@classmethod
def _from_cover_image(cls, state: _State, object_id: int, cover_image_hash: str) -> Self:
return cls(
state,
url=f'{cls.BASE}/app-assets/{object_id}/store/{cover_image_hash}.png?size=1024',
key=cover_image_hash,
animated=False,
)
@classmethod
def _from_scheduled_event_cover_image(cls, state: _State, scheduled_event_id: int, cover_image_hash: str) -> Self:
return cls(
@ -333,28 +324,6 @@ class Asset(AssetMixin):
animated=False,
)
@classmethod
def _from_application_asset(cls, state, app_id: int, hash: str) -> Asset:
animated = hash.startswith('a_')
format = 'gif' if animated else 'png'
return cls(
state,
url=f'{cls.BASE}/app-assets/{app_id}/{hash}.{format}',
key=hash,
animated=animated,
)
@classmethod
def _from_astore_asset(cls, state, app_id: int, hash: str) -> Asset:
animated = hash.startswith('a_')
format = 'gif' if animated else 'png'
return cls(
state,
url=f'{cls.BASE}/app-assets/{app_id}/{hash}.{format}',
key=hash,
animated=animated,
)
@classmethod
def _from_achievement_icon(cls, state, app_id: int, achievement_id: int, icon_hash: str) -> Asset:
return cls(

Loading…
Cancel
Save