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: Add Guild Member Cover & Accent Color support #1117
Merged
FedorLap2006
merged 9 commits into
bwmarrin:master
from
42atomys:feat/member_banner_support
Mar 2, 2022
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4d0a6c6
feat: add field to struct
42atomys 47c2431
feat(user): Add Banner support
42atomys 897e19f
Update user.go
42atomys b7d8a62
Update user.go
42atomys 4ee6861
docs(banner): Replace all cover word with banner
42atomys b382a09
docs(banner): Remove link on image formatting on banner
42atomys 8e00600
Update util.go
42atomys 473435a
feat(structs#Member): removed BannerURL
FedorLap2006 1a81f3f
fix(user): wording in comment to BannerURL
FedorLap2006 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,12 @@ type User struct { | |
// Whether the user has multi-factor authentication enabled. | ||
MFAEnabled bool `json:"mfa_enabled"` | ||
|
||
// The hash of the user's banner image. | ||
Banner string `json:"banner"` | ||
|
||
// User's banner color, encoded as an integer representation of hexadecimal color code | ||
AccentColor int `json:"accent_color"` | ||
|
||
// Whether the user is a bot. | ||
Bot bool `json:"bot"` | ||
|
||
|
@@ -92,3 +98,11 @@ func (u *User) AvatarURL(size string) string { | |
return avatarURL(u.Avatar, EndpointDefaultUserAvatar(u.Discriminator), | ||
EndpointUserAvatar(u.ID, u.Avatar), EndpointUserAvatarAnimated(u.ID, u.Avatar), size) | ||
} | ||
|
||
// BannerURL returns the URL of the member's banner image. | ||
// size: The size of the desired banner image as a power of two | ||
// Image size can be any power of two between 16 and 4096. | ||
func (u *User) BannerURL(size string) string { | ||
// The default/empty avatar case should be handled by the above condition | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this belongs to |
||
return bannerURL(u.Banner, EndpointUserBanner(u.ID, u.Banner), EndpointUserBannerAnimated(u.ID, u.Banner), size) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this would be necessary, since
Member
doesn't haveBanner
propertyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not actually implemented on Discord API v9 but custom banner per server is actually a feature of the Discord client (Available on
Edit Server Profile
). In Discord Client app, the app fallback to the user banner if the fieldbanner
of Member is null.I just added the fallback strategy now and wait the banner field to be released
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to just implement it when it goes out. DiscordGo is 1:1 mapping, so if API doesn't have it, we don't as well.