From bcda9c8eb267aa13a325c6961320fa724cdc7d1b Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Thu, 2 May 2024 23:55:34 +0200 Subject: [PATCH 1/2] Add clans --- discord/cdn_endpoints.go | 2 ++ discord/user.go | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/discord/cdn_endpoints.go b/discord/cdn_endpoints.go index 663f3725..8ae5cae1 100644 --- a/discord/cdn_endpoints.go +++ b/discord/cdn_endpoints.go @@ -29,6 +29,8 @@ var ( AvatarDecoration = NewCDN("/avatar-decoration-presets/{user.avatar.decoration.hash}", FileFormatPNG) + ClanBadge = NewCDN("/clan-badges/{guild.id}/{badge.hash}", FileFormatPNG, FileFormatJPEG, FileFormatWebP, FileFormatGIF) + ApplicationIcon = NewCDN("/app-icons/{application.id}/{icon.hash}", FileFormatPNG, FileFormatJPEG, FileFormatWebP) ApplicationCover = NewCDN("/app-assets/{application.id}/{cover.image.hash}", FileFormatPNG, FileFormatJPEG, FileFormatWebP) ApplicationAsset = NewCDN("/app-assets/{application.id}/{asset.id}", FileFormatPNG, FileFormatJPEG, FileFormatWebP) diff --git a/discord/user.go b/discord/user.go index f9218cd4..eac6e516 100644 --- a/discord/user.go +++ b/discord/user.go @@ -76,6 +76,7 @@ type User struct { System bool `json:"system"` PublicFlags UserFlags `json:"public_flags"` AvatarDecorationData *AvatarDecorationData `json:"avatar_decoration_data"` + Clan *Clan `json:"clan"` } // String returns a mention of the user @@ -152,6 +153,15 @@ func (u User) AvatarDecorationURL(opts ...CDNOpt) *string { return &url } +// ClanBadgeURL returns the clan badge URL if in a clan or nil +func (u User) ClanBadgeURL(opts ...CDNOpt) *string { + if u.Clan == nil { + return nil + } + url := formatAssetURL(ClanBadge, opts, u.Clan.Badge) + return &url +} + func (u User) CreatedAt() time.Time { return u.ID.Time() } @@ -203,3 +213,10 @@ type AvatarDecorationData struct { Asset string `json:"asset"` SkuID snowflake.ID `json:"sku_id"` } + +type Clan struct { + IdentityGuildID snowflake.ID `json:"identity_guild_id"` + IdentityEnabled bool `json:"identity_enabled"` + Tag string `json:"tag"` + Badge string `json:"badge"` +} From fa38ebf0fb62f13d3f3b39c20e04f4216235a6da Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Fri, 3 May 2024 00:13:34 +0200 Subject: [PATCH 2/2] fix url --- discord/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/user.go b/discord/user.go index eac6e516..61a95299 100644 --- a/discord/user.go +++ b/discord/user.go @@ -158,7 +158,7 @@ func (u User) ClanBadgeURL(opts ...CDNOpt) *string { if u.Clan == nil { return nil } - url := formatAssetURL(ClanBadge, opts, u.Clan.Badge) + url := formatAssetURL(ClanBadge, opts, u.Clan.IdentityGuildID, u.Clan.Badge) return &url }