feat: add guild member banners (#1592)
This commit is contained in:
parent
2d15f13e65
commit
d4827e8d77
2 changed files with 25 additions and 0 deletions
|
@ -115,6 +115,12 @@ var (
|
||||||
EndpointGuildMemberAvatarAnimated = func(gId, uID, aID string) string {
|
EndpointGuildMemberAvatarAnimated = func(gId, uID, aID string) string {
|
||||||
return EndpointCDNGuilds + gId + "/users/" + uID + "/avatars/" + aID + ".gif"
|
return EndpointCDNGuilds + gId + "/users/" + uID + "/avatars/" + aID + ".gif"
|
||||||
}
|
}
|
||||||
|
EndpointGuildMemberBanner = func(gId, uID, hash string) string {
|
||||||
|
return EndpointCDNGuilds + gId + "/users/" + uID + "/banners/" + hash + ".png"
|
||||||
|
}
|
||||||
|
EndpointGuildMemberBannerAnimated = func(gId, uID, hash string) string {
|
||||||
|
return EndpointCDNGuilds + gId + "/users/" + uID + "/banners/" + hash + ".gif"
|
||||||
|
}
|
||||||
|
|
||||||
EndpointRoleIcon = func(rID, hash string) string {
|
EndpointRoleIcon = func(rID, hash string) string {
|
||||||
return EndpointCDNRoleIcons + rID + "/" + hash + ".png"
|
return EndpointCDNRoleIcons + rID + "/" + hash + ".png"
|
||||||
|
|
19
structs.go
19
structs.go
|
@ -1566,6 +1566,9 @@ type Member struct {
|
||||||
// The hash of the avatar for the guild member, if any.
|
// The hash of the avatar for the guild member, if any.
|
||||||
Avatar string `json:"avatar"`
|
Avatar string `json:"avatar"`
|
||||||
|
|
||||||
|
// The hash of the banner for the guild member, if any.
|
||||||
|
Banner string `json:"banner"`
|
||||||
|
|
||||||
// The underlying user on which the member is based.
|
// The underlying user on which the member is based.
|
||||||
User *User `json:"user"`
|
User *User `json:"user"`
|
||||||
|
|
||||||
|
@ -1610,6 +1613,22 @@ func (m *Member) AvatarURL(size string) string {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 (m *Member) BannerURL(size string) string {
|
||||||
|
if m.Banner == "" {
|
||||||
|
return m.User.BannerURL(size)
|
||||||
|
}
|
||||||
|
return bannerURL(
|
||||||
|
m.Banner,
|
||||||
|
EndpointGuildMemberBanner(m.GuildID, m.User.ID, m.Banner),
|
||||||
|
EndpointGuildMemberBannerAnimated(m.GuildID, m.User.ID, m.Banner),
|
||||||
|
size,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// DisplayName returns the member's guild nickname if they have one,
|
// DisplayName returns the member's guild nickname if they have one,
|
||||||
// otherwise it returns their discord display name.
|
// otherwise it returns their discord display name.
|
||||||
func (m *Member) DisplayName() string {
|
func (m *Member) DisplayName() string {
|
||||||
|
|
Loading…
Reference in a new issue