Skip to content

Commit

Permalink
Update avatar decorations
Browse files Browse the repository at this point in the history
  • Loading branch information
mlnrDev committed Sep 29, 2023
1 parent 4d0bbb2 commit dd2fbb4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion discord/cdn_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 18 additions & 13 deletions discord/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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"`
}

0 comments on commit dd2fbb4

Please sign in to comment.