Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust default_avatar behavior depending on username #2087

Merged
merged 4 commits into from May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -78,6 +78,8 @@ These changes are available on the `master` branch, but have not yet been releas
- Embed attribues like author, footer, etc now return `None` when not set, and return
their respective classes when set.
([#2063](https://github.com/Pycord-Development/pycord/pull/2063))
- `default_avatar` behavior changes depending on the user's username migration status
([#2087](https://github.com/Pycord-Development/pycord/pull/2087))

### Removed

Expand Down
5 changes: 3 additions & 2 deletions discord/user.py
Expand Up @@ -195,9 +195,10 @@
@property
def default_avatar(self) -> Asset:
"""Returns the default avatar for a given user.
This is calculated by the user's ID.
This is calculated by the user's ID if they're on the new username system, otherwise their discriminator.
"""
return Asset._from_default_avatar(self._state, (self.id >> 22) % 5)
eq = (self.id >> 22) if self.is_migrated else int(self.discriminator)
return Asset._from_default_avatar(self._state, eq % 5)

Check warning on line 201 in discord/user.py

View check run for this annotation

Codecov / codecov/patch

discord/user.py#L200-L201

Added lines #L200 - L201 were not covered by tests

@property
def display_avatar(self) -> Asset:
Expand Down