Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clans #353

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.IdentityGuildID, 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"`
}
Loading