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

feat(member): implement member banners #1204

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Snipy7374
Copy link
Contributor

Summary

Note that this is still untested as the feature is not rolled out yet.

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running pdm lint
    • I have type-checked the code by running pdm pyright
  • This PR fixes an issue
  • This PR adds something new (e.g. new method or parameters)
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@shiftinv shiftinv added t: enhancement New feature t: api support Support of Discord API features s: waiting for api/docs Issue/PR is waiting for API support/documentation labels Jul 18, 2024
@shiftinv shiftinv added this to the disnake v2.10 milestone Jul 18, 2024
Copy link
Member

@shiftinv shiftinv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than those two comments, looks good to me! seems pretty straightforward.

disnake/member.py Show resolved Hide resolved
@@ -619,6 +621,17 @@ def guild_avatar(self) -> Optional[Asset]:
return None
return Asset._from_guild_avatar(self._state, self.guild.id, self.id, self._avatar)

@property
def guild_banner(self) -> Optional[Asset]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a display_banner field would be a good QOL addition, which also keeps it in line with avatars and decorations

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has no reason to exist, as it is non-functional, as the API only returns the user banners on fetched users.

Copy link
Member

@shiftinv shiftinv Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gateway doesn't send user banners, but REST does, so this works fine with guild.fetch_member which also returns user data for the requested member.
The caveat here is that the user can't be cached yet, since store_user will prefer the cached user (without banner) over the passed user data (with banner):

disnake/disnake/member.py

Lines 328 to 330 in 93de3c8

if user_data is None:
user_data = cast("MemberWithUserPayload", data)["user"]
self._user: User = state.store_user(user_data)

Improving this is out of scope here, but display_banner isn't completely useless either way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like how it functions, given its a bit of a footgun in its current state.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given its a bit of a footgun in its current state

hmm, fair enough; it is somewhat inconsistent.
In that case, I suppose display_banner would be better suited as a TODO for the future, once the MemberWithUserPayload handling improves a bit. Bit unfortunate, but you're right.

Copy link
Member

@shiftinv shiftinv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thank you!

disnake/member.py Outdated Show resolved Hide resolved
Co-authored-by: shiftinv <[email protected]>
Signed-off-by: Snipy7374 <[email protected]>
@@ -619,6 +621,17 @@ def guild_avatar(self) -> Optional[Asset]:
return None
return Asset._from_guild_avatar(self._state, self.guild.id, self.id, self._avatar)

@property
def guild_banner(self) -> Optional[Asset]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has no reason to exist, as it is non-functional, as the API only returns the user banners on fetched users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: waiting for api/docs Issue/PR is waiting for API support/documentation t: api support Support of Discord API features t: enhancement New feature
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

add support for member banners
3 participants