From 40dc8d1d9db3ee370ffed323c1a2bf92cc759747 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Tue, 22 Feb 2022 03:13:01 +0100 Subject: [PATCH] Change Webhook.avatar to be consistent with User.avatar --- discord/webhook/async_.py | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index 989b2b445..399872e0f 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -895,16 +895,35 @@ class BaseWebhook(Hashable): return utils.snowflake_time(self.id) @property - def avatar(self) -> Asset: - """:class:`Asset`: Returns an :class:`Asset` for the avatar the webhook has. + def avatar(self) -> Optional[Asset]: + """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 - the default avatar is returned instead. + If the webhook does not have a traditional avatar, ``None`` is returned. + If you want the avatar that a webhook has displayed, consider :attr:`display_avatar`. """ - if self._avatar is None: - # Default is always blurple apparently - return Asset._from_default_avatar(self._state, 0) - return Asset._from_avatar(self._state, self.id, self._avatar) + if self._avatar is not None: + return Asset._from_avatar(self._state, self.id, self._avatar) + return None + + @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):