Skip to content

Commit

Permalink
Add missing Image data to scheduled events
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 committed May 2, 2024
1 parent 8a19ae0 commit abe9a44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions discord/cdn_endpoints.go
Expand Up @@ -17,6 +17,8 @@ var (
GuildDiscoverySplash = NewCDN("/discovery-splashes/{guild.id}/{guild.discovery.splash.hash}", FileFormatPNG, FileFormatJPEG, FileFormatWebP)
GuildBanner = NewCDN("/banners/{guild.id}/{guild.banner.hash}", FileFormatPNG, FileFormatJPEG, FileFormatWebP, FileFormatGIF)

GuildScheduledEventCover = NewCDN("/guild-events/{event.id}/{event.cover.hash}", FileFormatPNG, FileFormatJPEG, FileFormatWebP)

RoleIcon = NewCDN("/role-icons/{role.id}/{role.icon.hash}", FileFormatPNG, FileFormatJPEG)

UserBanner = NewCDN("/banners/{user.id}/{user.banner.hash}", FileFormatPNG, FileFormatJPEG, FileFormatWebP, FileFormatGIF)
Expand Down
12 changes: 12 additions & 0 deletions discord/guild_scheduled_event.go
Expand Up @@ -3,6 +3,7 @@ package discord
import (
"time"

"github.com/disgoorg/json"
"github.com/disgoorg/snowflake/v2"
)

Expand All @@ -23,12 +24,22 @@ type GuildScheduledEvent struct {
EntityMetaData *EntityMetaData `json:"entity_metadata"`
Creator User `json:"creator"`
UserCount int `json:"user_count"`
Image *string `json:"image"`
}

func (e GuildScheduledEvent) CreatedAt() time.Time {
return e.ID.Time()
}

// CoverURL returns the cover URL if set or nil
func (e GuildScheduledEvent) CoverURL(opts ...CDNOpt) *string {
if e.Image == nil {
return nil
}
url := formatAssetURL(GuildScheduledEventCover, opts, e.ID, e.Image)
return &url
}

type GuildScheduledEventCreate struct {
ChannelID snowflake.ID `json:"channel_id,omitempty"`
EntityMetaData *EntityMetaData `json:"entity_metadata,omitempty"`
Expand All @@ -51,6 +62,7 @@ type GuildScheduledEventUpdate struct {
Description *string `json:"description,omitempty"`
EntityType *ScheduledEventEntityType `json:"entity_type,omitempty"`
Status *ScheduledEventStatus `json:"status,omitempty"`
Image *json.Nullable[Icon] `json:"image,omitempty"`
}

type GuildScheduledEventUser struct {
Expand Down

0 comments on commit abe9a44

Please sign in to comment.