Skip to content

Commit

Permalink
Add clans
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 committed May 2, 2024
1 parent 8a19ae0 commit bcda9c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions discord/cdn_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions discord/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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"`
}

0 comments on commit bcda9c8

Please sign in to comment.