Browse Source

Fix default_avatar for team user and webhook

pull/9932/head
owocado 7 months ago
committed by GitHub
parent
commit
0a2faa6f5d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      discord/user.py
  2. 9
      discord/webhook/async_.py

2
discord/user.py

@ -171,7 +171,7 @@ class BaseUser(_UserTag):
@property
def default_avatar(self) -> Asset:
""":class:`Asset`: Returns the default avatar for a given user."""
if self.discriminator == '0':
if self.discriminator in ('0', '0000'):
avatar_id = (self.id >> 22) % len(DefaultAvatar)
else:
avatar_id = int(self.discriminator) % 5

9
discord/webhook/async_.py

@ -38,7 +38,7 @@ import aiohttp
from .. import utils
from ..errors import HTTPException, Forbidden, NotFound, DiscordServerError
from ..message import Message
from ..enums import try_enum, WebhookType, ChannelType
from ..enums import try_enum, WebhookType, ChannelType, DefaultAvatar
from ..user import BaseUser, User
from ..flags import MessageFlags
from ..asset import Asset
@ -360,7 +360,7 @@ class AsyncWebhookAdapter:
multipart: Optional[List[Dict[str, Any]]] = None,
files: Optional[Sequence[File]] = None,
thread_id: Optional[int] = None,
) -> Response[Message]:
) -> Response[MessagePayload]:
route = Route(
'PATCH',
'/webhooks/{webhook_id}/{webhook_token}/messages/{message_id}',
@ -1049,12 +1049,11 @@ class BaseWebhook(Hashable):
@property
def default_avatar(self) -> Asset:
"""
:class:`Asset`: Returns the default avatar. This is always the blurple avatar.
:class:`Asset`: Returns the default avatar.
.. versionadded:: 2.0
"""
# Default is always blurple apparently
return Asset._from_default_avatar(self._state, 0)
return Asset._from_default_avatar(self._state, (self.id >> 22) % len(DefaultAvatar))
@property
def display_avatar(self) -> Asset:

Loading…
Cancel
Save