Change User.avatar to be Optional[Asset] instead of Asset

This change was needed to allow users to more easily check if an
uploaded avatar was set using `if user.avatar:` rather than the
admittedly clunky `if user.avatar != user.default_avatar.

The old behaviour with a fallback is still useful for actual display
purposes, so it has been moved over to the new `User.display_avatar`
attribute. This also has symmetry with the newly added
`Member.display_avatar` attribute.
This commit is contained in:
Rapptz
2021-08-25 01:42:29 -04:00
parent 78598d59d7
commit 848d752388
2 changed files with 18 additions and 21 deletions

View File

@ -275,7 +275,7 @@ class Member(discord.abc.Messageable, _UserTag):
system: bool
created_at: datetime.datetime
default_avatar: Asset
avatar: Asset
avatar: Optional[Asset]
dm_channel: Optional[DMChannel]
create_dm = User.create_dm
mutual_guilds: List[Guild]
@ -513,7 +513,7 @@ class Member(discord.abc.Messageable, _UserTag):
.. versionadded:: 2.0
"""
return self.guild_avatar or self.avatar
return self.guild_avatar or self._user.avatar or self._user.default_avatar
@property
def guild_avatar(self) -> Optional[Asset]: