embed

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxEmbedsPerMessage      = 10
	MaxFieldsPerEmbed        = 25
	MaxTotalTextCharacters   = 6000
	MaxTitleCharacters       = 256
	MaxDescriptionCharacters = 4096
	MaxFooterTextCharacters  = 2048
	MaxAuthorNameCharacters  = 256
	MaxFieldNameCharacters   = 256
	MaxFieldValueCharacters  = 1024
	MaxColorValue            = 16777215
)

Variables

This section is empty.

Functions

func MarshalEmbeds

func MarshalEmbeds(embeds []Embed) (string, error)

func ValidateEmbeds

func ValidateEmbeds(embeds []Embed) error

Types

type Embed

type Embed struct {
	Title       string         `json:"title,omitempty" example:"GoChat 1.0"`                                     // Embed title.
	Type        string         `json:"type,omitempty" example:"rich" enums:"rich,image,video,gifv,article,link"` // Embed type.
	Description string         `json:"description,omitempty" example:"Embed support is live."`                   // Main embed description.
	URL         string         `json:"url,omitempty" example:"https://example.com/release"`                      // Canonical URL opened when the embed title is clicked.
	Timestamp   *time.Time     `json:"timestamp,omitempty" swaggertype:"string" format:"date-time"`              // Optional ISO timestamp shown by the client.
	Color       *int           `json:"color,omitempty" example:"65280"`                                          // Decimal RGB color value.
	Footer      *EmbedFooter   `json:"footer,omitempty"`                                                         // Optional footer block.
	Image       *EmbedMedia    `json:"image,omitempty"`                                                          // Full-size image block.
	Thumbnail   *EmbedMedia    `json:"thumbnail,omitempty"`                                                      // Thumbnail image block.
	Video       *EmbedMedia    `json:"video,omitempty"`                                                          // Embedded video metadata.
	Provider    *EmbedProvider `json:"provider,omitempty"`                                                       // Content provider metadata.
	Author      *EmbedAuthor   `json:"author,omitempty"`                                                         // Embed author metadata.
	Fields      []EmbedField   `json:"fields,omitempty"`                                                         // Up to 25 structured fields.
}

Embed is a Discord-like message embed object.

func MergeEmbeds

func MergeEmbeds(groups ...[]Embed) []Embed

func ParseEmbeds

func ParseEmbeds(raw *string) ([]Embed, error)

func ParseMergedEmbeds

func ParseMergedEmbeds(manualRaw, autoRaw *string, suppressGenerated bool) ([]Embed, error)

type EmbedAuthor

type EmbedAuthor struct {
	Name         string `json:"name,omitempty" example:"The PrimeTime"`                                           // Author display name.
	URL          string `json:"url,omitempty" example:"https://www.youtube.com/channel/UCUyeluBRhGPCW4rPe_UvBZQ"` // Author URL.
	IconURL      string `json:"icon_url,omitempty" example:"https://example.com/author.png"`                      // Author icon URL.
	ProxyIconURL string `json:"proxy_icon_url,omitempty" example:"https://cdn.example.com/author.png"`            // Optional proxied author icon URL.
}

EmbedAuthor identifies the embed author or channel.

type EmbedField

type EmbedField struct {
	Name   string `json:"name" example:"Status"`           // Field label.
	Value  string `json:"value" example:"Stable"`          // Field value.
	Inline *bool  `json:"inline,omitempty" example:"true"` // Whether the field should be rendered inline.
}

EmbedField is a structured name/value row within an embed.

type EmbedFooter

type EmbedFooter struct {
	Text         string `json:"text,omitempty" example:"Documentation"`                              // Footer text.
	IconURL      string `json:"icon_url,omitempty" example:"https://example.com/icon.png"`           // Footer icon URL.
	ProxyIconURL string `json:"proxy_icon_url,omitempty" example:"https://cdn.example.com/icon.png"` // Optional proxied footer icon URL.
}

EmbedFooter is the footer block shown at the bottom of an embed.

type EmbedMedia

type EmbedMedia struct {
	URL                string `json:"url,omitempty" example:"https://example.com/preview.png"`           // Media URL.
	ProxyURL           string `json:"proxy_url,omitempty" example:"https://cdn.example.com/preview.png"` // Optional proxied media URL.
	Height             *int64 `json:"height,omitempty" example:"720"`                                    // Media height in pixels.
	Width              *int64 `json:"width,omitempty" example:"1280"`                                    // Media width in pixels.
	ContentType        string `json:"content_type,omitempty" example:"image/png"`                        // Media MIME type when known.
	Placeholder        string `json:"placeholder,omitempty" example:"IPgNDIQbRUaQiJcwuYlwmyQ5Bg=="`      // Encoded placeholder used by some generated embeds.
	PlaceholderVersion *int   `json:"placeholder_version,omitempty" example:"1"`                         // Placeholder format version.
	Flags              *int   `json:"flags,omitempty" example:"0"`                                       // Media-specific flags from the source provider.
}

EmbedMedia describes image, thumbnail, or video media attached to an embed.

type EmbedProvider

type EmbedProvider struct {
	Name string `json:"name,omitempty" example:"YouTube"`                // Provider name.
	URL  string `json:"url,omitempty" example:"https://www.youtube.com"` // Provider URL.
}

EmbedProvider identifies the site or service that produced an embed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL