Browse Source

Add avatar_decoration to more places

pull/10109/head
dolfies 2 years ago
parent
commit
77b7c5a2a5
  1. 8
      discord/abc.py
  2. 1
      discord/member.py
  3. 12
      discord/user.py

8
discord/abc.py

@ -347,6 +347,14 @@ class User(Snowflake, Protocol):
"""Optional[:class:`~discord.Asset`]: Returns an Asset that represents the user's avatar, if present."""
raise NotImplementedError
@property
def avatar_decoration(self) -> Optional[Asset]:
"""Optional[:class:`~discord.Asset`]: Returns an Asset that represents the user's avatar decoration, if present.
.. versionadded:: 2.0
"""
raise NotImplementedError
@property
def default_avatar(self) -> Asset:
""":class:`~discord.Asset`: Returns the default avatar for a given user. This is calculated by the user's discriminator."""

1
discord/member.py

@ -289,6 +289,7 @@ class Member(discord.abc.Messageable, discord.abc.Connectable, _UserTag):
created_at: datetime.datetime
default_avatar: Asset
avatar: Optional[Asset]
avatar_decoration: Optional[Asset]
dm_channel: Optional[DMChannel]
create_dm: Callable[[], Awaitable[DMChannel]]
mutual_guilds: List[Guild]

12
discord/user.py

@ -887,12 +887,18 @@ class User(BaseUser, discord.abc.Connectable, discord.abc.Messageable):
if len(user) == 0 or len(user) <= 1: # Done because of typing
return
original = (self.name, self._avatar, self.discriminator, self._public_flags)
original = (self.name, self._avatar, self.discriminator, self._public_flags, self._avatar_decoration)
# These keys seem to always be available
modified = (user['username'], user.get('avatar'), user['discriminator'], user.get('public_flags', 0))
modified = (
user['username'],
user.get('avatar'),
user['discriminator'],
user.get('public_flags', 0),
user.get('avatar_decoration'),
)
if original != modified:
to_return = User._copy(self)
self.name, self._avatar, self.discriminator, self._public_flags = modified
self.name, self._avatar, self.discriminator, self._public_flags, self._avatar_decoration = modified
# Signal to dispatch user_update
return to_return, self

Loading…
Cancel
Save