Documentation ¶
Overview ¶
Package discord is a go library to quickly send events to discord channels To get started: Create a Webhook on the server, noting down the webhook URL. Then, in your application set the webhook URL variable and then you can use `Say` for a simple text message, or `Post` for a more complex message.
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"` }
Author describes the author for an embed
type Embed ¶
type Embed struct { Author *Author `json:"author,omitempty"` Title string `json:"title,omitempty"` URL string `json:"url,omitempty"` Description string `json:"description,omitempty"` Color uint32 `json:"color,omitempty"` Fields []Field `json:"fields,omitempty"` Thumbnail *Image `json:"thumbnail,omitempty"` Image *Image `json:"image,omitempty"` }
Embed describes embedded content within a message
type Field ¶
type Field struct { Name string `json:"name,omitempty"` Value string `json:"value,omitempty"` Inline bool `json:"inline,omitempty"` }
Field describes a field for an embed
type FileOptions ¶
type FileOptions struct { // The file name must include an extension and not include any directories FileName string Reader io.Reader }
FileOptions describes the options for uploading a file
type Image ¶
type Image struct {
URL string `json:"url,omitempty"`
}
Image describes an image for an embed. If you need to upload an image you must use the `discord.UploadFile()` method, however that does not support rich embeds.
type PostOptions ¶
type PostOptions struct { Username string `json:"username,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` Content string `json:"content,omitempty"` Embeds []Embed `json:"embeds,omitempty"` }
PostOptions describes all possible options for a post
type Webhook ¶
type Webhook struct {
// contains filtered or unexported fields
}
Webhook main struct
func (*Webhook) Post ¶
func (w *Webhook) Post(content PostOptions) error
Post will post a message to the channel for which the webhook is configured. Unlike `discord.Say()`, Post gives you full control over the message.
func (*Webhook) Say ¶
Say sends the provided message to the channel for which the webhook is configured. If WebhookURL is not set, this does nothing.
func (*Webhook) UploadFile ¶
func (w *Webhook) UploadFile(content PostOptions, file FileOptions) error
UploadFile will post a message to the channel for which the webhook is configured and attach the specified file to your message. Rich embeds are not supported and will be ignored if any are specified.