embed

package
v0.0.0-...-a121215 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeRich    = "rich"
	TypeImage   = "image"
	TypeVideo   = "video"
	TypeGIFV    = "gifv"
	TypeArticle = "article"
	TypeLink    = "link"
)

Variables

This section is empty.

Functions

func Inline

func Inline(message string, color ...int) *discordgo.MessageEmbed

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) AddField

func (b *Builder) AddField(name, value string, inline bool) *Builder

func (*Builder) Author

func (b *Builder) Author(name, url, iconURL, proxyIconURL string) *Builder

func (*Builder) AuthorSimple

func (b *Builder) AuthorSimple(name string) *Builder

func (*Builder) Build

func (b *Builder) Build() *discordgo.MessageEmbed

func (*Builder) Color

func (b *Builder) Color(color int) *Builder

func (*Builder) Description

func (b *Builder) Description(desc string) *Builder

func (*Builder) Footer

func (b *Builder) Footer(text, iconURL, iconProxyURL string) *Builder

func (*Builder) FooterSimple

func (b *Builder) FooterSimple(text string) *Builder

func (*Builder) Image

func (b *Builder) Image(url, proxyURL string, height, width int) *Builder

func (*Builder) ImageSimple

func (b *Builder) ImageSimple(url string) *Builder

func (*Builder) InLimits

func (b *Builder) InLimits() bool

func (*Builder) LimitExceeds

func (b *Builder) LimitExceeds() []string

func (*Builder) Provider

func (b *Builder) Provider(name, url string) *Builder

func (*Builder) Reset

func (b *Builder) Reset() *Builder

Reset renew the underlying embed for avoid cases when you don't need to create new builder

func (*Builder) Thumbnail

func (b *Builder) Thumbnail(url, proxyURL string, height, width int) *Builder

func (*Builder) ThumbnailSimple

func (b *Builder) ThumbnailSimple(url string) *Builder

func (*Builder) Timestamp

func (b *Builder) Timestamp(t *time.Time) *Builder

func (*Builder) Title

func (b *Builder) Title(title string) *Builder

func (*Builder) Type

func (b *Builder) Type(embedType string) *Builder

func (*Builder) URL

func (b *Builder) URL(url string) *Builder

func (*Builder) Video

func (b *Builder) Video(url, proxyURL string, height, width int) *Builder

func (*Builder) VideoSimple

func (b *Builder) VideoSimple(url string) *Builder

Jump to

Keyboard shortcuts

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