From dd2fbb43c41d02e382af642b2e8b315a44ef6b9d Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Fri, 29 Sep 2023 12:54:23 +0200 Subject: [PATCH] Update avatar decorations --- discord/cdn_endpoints.go | 2 +- discord/user.go | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/discord/cdn_endpoints.go b/discord/cdn_endpoints.go index 8186af5a..6cffdfeb 100644 --- a/discord/cdn_endpoints.go +++ b/discord/cdn_endpoints.go @@ -24,7 +24,7 @@ var ( MemberAvatar = NewCDN("/guilds/{guild.id}/users/{user.id}/avatars/{member.avatar.hash}", FileFormatPNG, FileFormatJPEG, FileFormatWebP, FileFormatGIF) - UserAvatarDecoration = NewCDN("/avatar-decorations/{user.id}/{user.avatar.decoration.hash}", FileFormatPNG) + AvatarDecoration = NewCDN("/avatar-decoration-presets/{user.avatar.decoration.hash}", FileFormatPNG) ApplicationIcon = NewCDN("/app-icons/{application.id}/{icon.hash}", FileFormatPNG, FileFormatJPEG, FileFormatWebP) ApplicationCover = NewCDN("/app-assets/{application.id}/{cover.image.hash}", FileFormatPNG, FileFormatJPEG, FileFormatWebP) diff --git a/discord/user.go b/discord/user.go index caa63b8d..7358c735 100644 --- a/discord/user.go +++ b/discord/user.go @@ -65,17 +65,17 @@ var _ Mentionable = (*User)(nil) // User is a struct for interacting with discord's users type User struct { - ID snowflake.ID `json:"id"` - Username string `json:"username"` - Discriminator string `json:"discriminator"` - GlobalName *string `json:"global_name"` - Avatar *string `json:"avatar"` - Banner *string `json:"banner"` - AccentColor *int `json:"accent_color"` - Bot bool `json:"bot"` - System bool `json:"system"` - PublicFlags UserFlags `json:"public_flags"` - AvatarDecoration *string `json:"avatar_decoration"` + ID snowflake.ID `json:"id"` + Username string `json:"username"` + Discriminator string `json:"discriminator"` + GlobalName *string `json:"global_name"` + Avatar *string `json:"avatar"` + Banner *string `json:"banner"` + AccentColor *int `json:"accent_color"` + Bot bool `json:"bot"` + System bool `json:"system"` + PublicFlags UserFlags `json:"public_flags"` + AvatarDecorationData *AvatarDecorationData `json:"avatar_decoration_data"` } // String returns a mention of the user @@ -145,10 +145,10 @@ func (u User) BannerURL(opts ...CDNOpt) *string { // AvatarDecorationURL returns the avatar decoration URL if set or nil func (u User) AvatarDecorationURL(opts ...CDNOpt) *string { - if u.AvatarDecoration == nil { + if u.AvatarDecorationData == nil { return nil } - url := formatAssetURL(UserAvatarDecoration, opts, u.ID, *u.AvatarDecoration) + url := formatAssetURL(AvatarDecoration, opts, u.AvatarDecorationData.Asset) return &url } @@ -198,3 +198,8 @@ type ApplicationRoleConnectionUpdate struct { PlatformUsername *string `json:"platform_username,omitempty"` Metadata *map[string]string `json:"metadata,omitempty"` } + +type AvatarDecorationData struct { + Asset string `json:"asset"` + SkuID snowflake.ID `json:"sku_id"` +}