Skip to content

Commit 0bf2103

Browse files
twoscottdiamondburned
authored andcommitted
discord: Add Member BannerURL methods
1 parent b01afe1 commit 0bf2103

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

discord/guild.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ type Member struct {
388388
RoleIDs []RoleID `json:"roles"`
389389
// Avatar is this member's guild avatar.
390390
Avatar Hash `json:"avatar,omitempty"`
391+
// Banner is this member's guild banner.
392+
Banner Hash `json:"banner,omitempty"`
391393

392394
// Joined specifies when the user joined the guild.
393395
Joined Timestamp `json:"joined_at"`
@@ -431,6 +433,24 @@ func (m Member) AvatarURLWithType(t ImageType, guildID GuildID) string {
431433
return "https://cdn.discordapp.com/guilds/" + guildID.String() + "/users/" + m.User.ID.String() + "/avatars/" + t.format(m.Avatar)
432434
}
433435

436+
// BannerURL returns the URL of the Banner Image. It automatically detects a
437+
// suitable image type.
438+
func (m Member) BannerURL(guildID GuildID) string {
439+
return m.BannerURLWithType(AutoImage, guildID)
440+
}
441+
442+
// BannerURLWithType returns the URL of the Banner Image using the passed type.
443+
// If the member has no Banner, an empty string will be returned.
444+
//
445+
// Supported Image Types: PNG, JPEG, WebP, GIF
446+
func (m Member) BannerURLWithType(t ImageType, guildID GuildID) string {
447+
if m.Banner == "" {
448+
return ""
449+
}
450+
451+
return "https://cdn.discordapp.com/guilds/" + guildID.String() + "/users/" + m.User.ID.String() + "/banners/" + t.format(m.Banner)
452+
}
453+
434454
// MemberFlags represents the bit set of member flags.
435455
type MemberFlags uint32
436456

0 commit comments

Comments
 (0)