Documentation ¶
Overview ¶
Package embed contains builders to create Discord rich messages.
Here is an example of how to create a complex embed :
e := embed.New(). Author( embed.NewAuthor(). Name("author name"). IconURL("http://example.org/icon.png"). Build(), ). Title("title"). Description("description"). Color(0x3277ce). Fields( embed.NewField().Name("field 1").Value("value 1").Build(), embed.NewField().Name("field 2").Value("value 2").Build(), Footer(embed.NewFooter().Text("footer").Build()). Build()
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Author ¶
type Author struct { Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` IconURL string `json:"icon_url,omitempty"` ProxyIconURL string `json:"proxy_icon_url,omitempty"` }
Author is the embedded author in a Discord message.
type AuthorBuilder ¶
type AuthorBuilder interface { Name(n string) AuthorBuilder URL(url string) AuthorBuilder IconURL(url string) AuthorBuilder Build() *Author }
AuthorBuilder creates authors for messages with rich embedded content.
type Builder ¶
type Builder interface { Title(t string) Builder Description(t string) Builder URL(u string) Builder Timestamp(t time.Time) Builder Color(c int) Builder Image(i *Image) Builder Thumbnail(i *Thumbnail) Builder Author(i *Author) Builder Fields(fields ...*Field) Builder Build() *Embed }
Builder allows to add rich embedded content to Discord messages.
type Embed ¶
type Embed struct { Title string `json:"title,omitempty"` Type string `json:"type,omitempty"` // Type of embed (always "rich" for webhook embeds). Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` Timestamp *time.Time `json:"timestamp,omitempty"` Color int `json:"color,omitempty"` Image *Image `json:"image,omitempty"` Thumbnail *Thumbnail `json:"thumbnail,omitempty"` Video *Video `json:"video,omitempty"` Provider *Provider `json:"provider,omitempty"` Author *Author `json:"author,omitempty"` Fields []Field `json:"fields,omitempty"` }
Embed describes some rich content for a Discord message.
type Field ¶
type Field struct { Name string `json:"name,omitempty"` Value string `json:"value,omitempty"` Inline bool `json:"inline,omitempty"` }
Field is an embedded field in a Discord message.
type FieldBuilder ¶
type FieldBuilder interface { Name(url string) FieldBuilder Value(v string) FieldBuilder Inline(yes bool) FieldBuilder Build() *Field }
FieldBuilder creates fields for messages with rich embedded content.
type FooterBuilder ¶
type FooterBuilder interface {}
FooterBuilder creates footers for messages with rich embedded content.
type Image ¶
type Image struct { URL string `json:"url,omitempty"` // Source url of image (only supports http(s) and attachments). ProxyURL string `json:"proxy_url,omitempty"` // A proxied url of the image. Height int `json:"height,omitempty"` Width int `json:"width,omitempty"` }
Image is an embedded image in a Discord Message.
type Thumbnail ¶
type Thumbnail struct { URL string `json:"url,omitempty"` ProxyURL string `json:"proxy_url,omitempty"` Height int `json:"height,omitempty"` Width int `json:"width,omitempty"` }
Thumbnail is an embedded thumbnail in a Discord Message.
func NewThumbnail ¶
NewThumbnail creates an embedded thumbnail from its source URL. Supported formats are JPEG, PNG, WebP and GIF.