Browse Source

Change Webhook.avatar to be consistent with User.avatar

pull/7494/head
jack1142 3 years ago
committed by GitHub
parent
commit
40dc8d1d9d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      discord/webhook/async_.py

35
discord/webhook/async_.py

@ -895,16 +895,35 @@ class BaseWebhook(Hashable):
return utils.snowflake_time(self.id) return utils.snowflake_time(self.id)
@property @property
def avatar(self) -> Asset: def avatar(self) -> Optional[Asset]:
""":class:`Asset`: Returns an :class:`Asset` for the avatar the webhook has. """Optional[:class:`Asset`]: Returns an :class:`Asset` for the avatar the webhook has.
If the webhook does not have a traditional avatar, an asset for If the webhook does not have a traditional avatar, ``None`` is returned.
the default avatar is returned instead. If you want the avatar that a webhook has displayed, consider :attr:`display_avatar`.
""" """
if self._avatar is None: if self._avatar is not None:
# Default is always blurple apparently return Asset._from_avatar(self._state, self.id, self._avatar)
return Asset._from_default_avatar(self._state, 0) return None
return Asset._from_avatar(self._state, self.id, self._avatar)
@property
def default_avatar(self) -> Asset:
"""
:class:`Asset`: Returns the default avatar. This is always the blurple avatar.
.. versionadded:: 2.0
"""
# Default is always blurple apparently
return Asset._from_default_avatar(self._state, 0)
@property
def display_avatar(self) -> Asset:
""":class:`Asset`: Returns the webhook's display avatar.
This is either webhook's default avatar or uploaded avatar.
.. versionadded:: 2.0
"""
return self.avatar or self.default_avatar
class Webhook(BaseWebhook): class Webhook(BaseWebhook):

Loading…
Cancel
Save