From 669b316065eb95b141c8d7a3f1e24bf2b206ae30 Mon Sep 17 00:00:00 2001 From: sebm253 <42180891+sebm253@users.noreply.github.com> Date: Thu, 23 Jan 2025 12:39:21 +0100 Subject: [PATCH] Add new fields to Attachment and Embed --- discord/attachment.go | 34 ++++++++++++++++++++-------------- discord/embed.go | 25 +++++++++++++++++++++---- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/discord/attachment.go b/discord/attachment.go index 8d67b40b..e84ae0ca 100644 --- a/discord/attachment.go +++ b/discord/attachment.go @@ -8,20 +8,23 @@ import ( // Attachment is used for files sent in a Message type Attachment struct { - ID snowflake.ID `json:"id,omitempty"` - Filename string `json:"filename,omitempty"` - Title *string `json:"title,omitempty"` - Description *string `json:"description,omitempty"` - ContentType *string `json:"content_type,omitempty"` - Size int `json:"size,omitempty"` - URL string `json:"url,omitempty"` - ProxyURL string `json:"proxy_url,omitempty"` - Height *int `json:"height,omitempty"` - Width *int `json:"width,omitempty"` - Ephemeral bool `json:"ephemeral,omitempty"` - DurationSecs *float64 `json:"duration_secs,omitempty"` - Waveform *string `json:"waveform,omitempty"` - Flags AttachmentFlags `json:"flags"` + ID snowflake.ID `json:"id,omitempty"` + Filename string `json:"filename,omitempty"` + Title *string `json:"title,omitempty"` + Description *string `json:"description,omitempty"` + ContentType *string `json:"content_type,omitempty"` + Size int `json:"size,omitempty"` + URL string `json:"url,omitempty"` + ProxyURL string `json:"proxy_url,omitempty"` + Height *int `json:"height,omitempty"` + Width *int `json:"width,omitempty"` + Ephemeral bool `json:"ephemeral,omitempty"` + DurationSecs *float64 `json:"duration_secs,omitempty"` + Waveform *string `json:"waveform,omitempty"` + Flags AttachmentFlags `json:"flags"` + ClipParticipants []User `json:"clip_participants,omitempty"` + ClipCreatedAt *time.Time `json:"clip_created_at,omitempty"` + Application *Application `json:"application,omitempty"` } func (a Attachment) CreatedAt() time.Time { @@ -34,6 +37,9 @@ const ( AttachmentFlagIsClip AttachmentFlags = 1 << iota AttachmentFlagIsThumbnail AttachmentFlagIsRemix + AttachmentFlagIsSpoiler + AttachmentFlagContainsExplicitMedia + AttachmentFlagIsAnimated AttachmentFlagsNone AttachmentFlags = 0 ) diff --git a/discord/embed.go b/discord/embed.go index 30512902..8a686bdf 100644 --- a/discord/embed.go +++ b/discord/embed.go @@ -32,6 +32,7 @@ type Embed struct { Provider *EmbedProvider `json:"provider,omitempty"` Author *EmbedAuthor `json:"author,omitempty"` Fields []EmbedField `json:"fields,omitempty"` + Flags EmbedFlags `json:"flags,omitempty"` } func (e Embed) FindField(fieldFindFunc func(field EmbedField) bool) (EmbedField, bool) { @@ -53,14 +54,30 @@ func (e Embed) FindAllFields(fieldFindFunc func(field EmbedField) bool) []EmbedF return fields } +type EmbedFlags int + +const ( + EmbedFlagContainsExplicitMedia EmbedFlags = 1 << (iota + 4) + EmbedFlagIsContentInventoryEntry + EmbedFlagsNone EmbedFlags = 0 +) + // The EmbedResource of an Embed.Image/Embed.Thumbnail/Embed.Video type EmbedResource struct { - URL string `json:"url,omitempty"` - ProxyURL string `json:"proxy_url,omitempty"` - Height int `json:"height,omitempty"` - Width int `json:"width,omitempty"` + URL string `json:"url,omitempty"` + ProxyURL string `json:"proxy_url,omitempty"` + Height int `json:"height,omitempty"` + Width int `json:"width,omitempty"` + Flags EmbedResourceFlags `json:"flags,omitempty"` } +type EmbedResourceFlags int + +const ( + EmbedResourceFlagIsAnimated EmbedResourceFlags = 1 << 5 + EmbedResourceFlagsNone EmbedResourceFlags = 0 +) + // The EmbedProvider of an Embed type EmbedProvider struct { Name string `json:"name,omitempty"`