Documentation ¶
Index ¶
- Constants
- func Inline(message string, color ...int) *discordgo.MessageEmbed
- type Builder
- func (b *Builder) AddField(name, value string, inline bool) *Builder
- func (b *Builder) Author(name, url, iconURL, proxyIconURL string) *Builder
- func (b *Builder) AuthorSimple(name string) *Builder
- func (b *Builder) Build() *discordgo.MessageEmbed
- func (b *Builder) Color(color int) *Builder
- func (b *Builder) Description(desc string) *Builder
- func (b *Builder) Footer(text, iconURL, iconProxyURL string) *Builder
- func (b *Builder) FooterSimple(text string) *Builder
- func (b *Builder) Image(url, proxyURL string, height, width int) *Builder
- func (b *Builder) ImageSimple(url string) *Builder
- func (b *Builder) InLimits() bool
- func (b *Builder) LimitExceeds() []string
- func (b *Builder) Provider(name, url string) *Builder
- func (b *Builder) Reset() *Builder
- func (b *Builder) Thumbnail(url, proxyURL string, height, width int) *Builder
- func (b *Builder) ThumbnailSimple(url string) *Builder
- func (b *Builder) Timestamp(t *time.Time) *Builder
- func (b *Builder) Title(title string) *Builder
- func (b *Builder) Type(embedType string) *Builder
- func (b *Builder) URL(url string) *Builder
- func (b *Builder) Video(url, proxyURL string, height, width int) *Builder
- func (b *Builder) VideoSimple(url string) *Builder
Constants ¶
View Source
const ( TypeRich = "rich" TypeImage = "image" TypeVideo = "video" TypeGIFV = "gifv" TypeArticle = "article" TypeLink = "link" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder using for build embed and check embed field limits
------------------------------
You can use Example 1 if you sure about data length which will use for builder ¶
Example 1:
eb := embed.NewBuilder(). Image("https://example.com/img/fh982h93.jpg", "", 0, 0). FooterSimple("Look at this awesome picture!") if _, err := s.ChannelMessageSendEmbed("92963946923497253235", eb.Build()); err != nil { fmt.Println("Failed to send message with embed:", err) }
------------------------------
If you not sure about data length, which you use for building embed, you can use builder like in Example 2 ¶
Example 2:
eb := embed.NewBuilder(). Image("https://example.com/img/fh982h93.jpg", "", 0, 0). FooterSimple("Look at this awesome picture!") if !eb.InLimits() { fmt.Println("Failed to build discord embed") for _, exceed := range eb.LimitExceeds() { fmt.Println("Embed exceeded limit:", exceed) } } em := eb.Build() if _, err := s.ChannelMessageSendEmbed("92963946923497253235", em); err != nil { fmt.Println("Failed to send message with embed:", err) }
func NewBuilder ¶
func NewBuilder() *Builder
NewBuilder creates new embed builder with underlying embed and limits Default underlying embed has default type `rich` and color `#ffffff`
func (*Builder) AuthorSimple ¶
func (*Builder) Build ¶
func (b *Builder) Build() *discordgo.MessageEmbed
func (*Builder) Description ¶
func (*Builder) FooterSimple ¶
func (*Builder) ImageSimple ¶
func (*Builder) LimitExceeds ¶
func (*Builder) Reset ¶
Reset renew the underlying embed for avoid cases when you don't need to create new builder
func (*Builder) ThumbnailSimple ¶
func (*Builder) VideoSimple ¶
Click to show internal directories.
Click to hide internal directories.