discord

package
v0.0.0-...-0ad4d90 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultUsername  = "Web API"
	DefaultAvatarURL = "https://avatars.githubusercontent.com/u/115051386?s=200&v=4"
)
View Source
var (
	ErrWebhookNotConfigured = errors.New("webhook not configured")
	ErrUsedDefaultWebhook   = errors.New("webhook not configured, used default webhook")
)

Functions

func GetColor

func GetColor(red, green, blue string) int

Convert RGB hex values to integer

func SendWebhookMessage deprecated

func SendWebhookMessage(name string, username, msg string) error

Deprecated: use SendWebhookMessageObj instead

func SendWebhookMessageObj

func SendWebhookMessageObj(name string, msg Message) error

func SetupWebhooks

func SetupWebhooks(hooks map[string]string)

Types

type Author

type Author struct {
	Name    *string `json:"name,omitempty"`
	URL     *string `json:"URL,omitempty"`
	IconURL *string `json:"icon_URL,omitempty"`
}

type Embed

type Embed struct {
	Title       *string    `json:"title,omitempty"`
	URL         *string    `json:"URL,omitempty"`
	Description *string    `json:"description,omitempty"`
	Color       *int       `json:"color,omitempty"`
	Author      *Author    `json:"author,omitempty"`
	Fields      []*Field   `json:"fields,omitempty"`
	Thumbnail   *Thumbnail `json:"thumbnail,omitempty"`
	Image       *Image     `json:"image,omitempty"`
	Footer      *Footer    `json:"footer,omitempty"`
}

func NewEmbed

func NewEmbed() *Embed

func (*Embed) AddField

func (e *Embed) AddField(f *Field) *Embed

func (*Embed) SetAuthor

func (e *Embed) SetAuthor(a *Author) *Embed

func (*Embed) SetColor

func (e *Embed) SetColor(color int) *Embed

func (*Embed) SetDescription

func (e *Embed) SetDescription(desc string) *Embed

func (*Embed) SetFooter

func (e *Embed) SetFooter(f *Footer) *Embed

func (*Embed) SetImage

func (e *Embed) SetImage(i *Image) *Embed

func (*Embed) SetThumbnail

func (e *Embed) SetThumbnail(t *Thumbnail) *Embed

func (*Embed) SetTitle

func (e *Embed) SetTitle(title string) *Embed

func (*Embed) SetURL

func (e *Embed) SetURL(url string) *Embed

type Field

type Field struct {
	Name   *string `json:"name,omitempty"`
	Value  *string `json:"value,omitempty"`
	Inline *bool   `json:"inline,omitempty"`
}

func NewField

func NewField() *Field

func (*Field) SetInline

func (f *Field) SetInline(inline bool) *Field

func (*Field) SetName

func (f *Field) SetName(name string) *Field

func (*Field) SetValue

func (f *Field) SetValue(value string) *Field
type Footer struct {
	Text    *string `json:"text,omitempty"`
	IconURL *string `json:"icon_URL,omitempty"`
}

type Image

type Image struct {
	URL *string `json:"URL,omitempty"`
}

type Message

type Message struct {
	Username  *string  `json:"username,omitempty"`
	AvatarURL *string  `json:"avatar_URL,omitempty"`
	Content   *string  `json:"content,omitempty"`
	Embeds    []*Embed `json:"embeds,omitempty"`
}

func NewMessage

func NewMessage() *Message

func (*Message) AddEmbed

func (m *Message) AddEmbed(e *Embed) *Message

func (*Message) Send

func (m *Message) Send(webhook string) error

func (*Message) SetAvatarURL

func (m *Message) SetAvatarURL(url string) *Message

func (*Message) SetContent

func (m *Message) SetContent(content string) *Message

func (*Message) SetUsername

func (m *Message) SetUsername(username string) *Message

type Thumbnail

type Thumbnail struct {
	URL *string `json:"URL,omitempty"`
}

Jump to

Keyboard shortcuts

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