Documentation ¶
Index ¶
- Variables
- func CheckResponse(response *http.Response) (body []byte, err error)
- func FormatTime(Time time.Time) string
- type APIError
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFooter
- type EmbedImage
- type EmbedProvider
- type EmbedThumbnail
- type EmbedVideo
- type Webhook
- func (w *Webhook) Delete() (response []byte, err error)
- func (w *Webhook) Get() error
- func (w *Webhook) Modify(update *WebhookUpdate) (response []byte, err error)
- func (w *Webhook) SendFile(file []byte, filename string, message *WebhookMessage) (response []byte, err error)
- func (w *Webhook) SendMessage(message *WebhookMessage) (response []byte, err error)
- func (w *Webhook) URL() string
- type WebhookMessage
- type WebhookType
- type WebhookUpdate
Constants ¶
This section is empty.
Variables ¶
var ErrParseWebhook = errors.New("Provided URL is not a Discord webhook URL")
ErrParseWebhook represents error from `WebhookFromURL`
Functions ¶
func CheckResponse ¶
CheckResponse is a help func to check responses from discord API for errors `body` contains response from the server and probably will contain error information if it hasn't been parsed to `*APIError` type.
func FormatTime ¶
FormatTime is a help func to format time in ISO8601 format.
Types ¶
type APIError ¶
type APIError struct { HTTPResponse int `json:"http_response"` Code int `json:"code"` Message string `json:"message"` }
APIError represents discord answer to the request if it went wrong. https://discordapp.com/developers/docs/topics/opcodes-and-status-codes
type Embed ¶
type Embed struct { // Title of embed Title string `json:"title"` // Type of embed (always "rich" for webhook embeds) Type string `json:"type"` // Description of embed Description string `json:"description"` // URL of embed URL string `json:"url"` // Timestamp of embed content. Should be in ISO8601 format. Timestamp string `json:"timestamp"` // Color code of the embed Color int `json:"color"` Image *EmbedImage `json:"image"` Thumbnail *EmbedThumbnail `json:"thumbnail"` Video *EmbedVideo `json:"video"` Provider *EmbedProvider `json:"provider"` Author *EmbedAuthor `json:"author"` Fields []*EmbedField `json:"fields"` }
Embed represents discord embed. https://discordapp.com/developers/docs/resources/channel#embed-object
type EmbedAuthor ¶
type EmbedAuthor struct { // Name of author Name string `json:"name"` // URL of author URL string `json:"url"` // URL of author icon (only supports http(s) and attachments) IconURL string `json:"icon_url"` // Proxied URL of author icon ProxyIconURL string `json:"proxy_icon_url"` }
EmbedAuthor represents author of the embed
type EmbedField ¶
type EmbedField struct { // Name of the field. Required. Name string `json:"name"` // Value of the field. Required. Value string `json:"value"` // Whether or not this field should display inline. Inline bool `json:"inline"` }
EmbedField represents embed field
type EmbedFooter ¶
type EmbedFooter struct { string `json:"text"` IconURL string `json:"icon_url"` ProxyIconURL string `json:"proxy_icon_url"` }Text
Embed footer represents embed's footer
type EmbedImage ¶
type EmbedImage struct { // URL source of image (only supports http(s) and attachments) URL string `json:"url"` // A proxied url of the image ProxyURL string `json:"proxy_url"` // Height of image Height int `json:"height"` // Width of image Width int `json:"width"` }
EmbedImage represents Image that would be inside of the embed
type EmbedProvider ¶
type EmbedThumbnail ¶
type EmbedVideo ¶
type EmbedVideo struct { // URL source of video URL string `json:"url"` // Height of video Height int `json:"height"` // Width of video Width int `json:"width"` }
EmbedVideo represents Video that would be inside of the embed
type Webhook ¶
type Webhook struct { // ID of the webhook ID string `json:"id"` // Type is WebhookType Type WebhookType `json:"type"` GuildID string `json:"guild_id"` ChannelID string `json:"channel_id"` Name string `json:"name"` Avatar string `json:"avatar"` Token string `json:"token"` }
Webhook is a representation of discord webhooks
func WebhookFromURL ¶
WebhookFromURL parses URL and returns Webhook struct.
func (*Webhook) Get ¶
Get gets information about webhook. Useful to get name, guild and channel IDs etc.
func (*Webhook) Modify ¶
func (w *Webhook) Modify(update *WebhookUpdate) (response []byte, err error)
Modify modifies webhook at the client and discord side.
func (*Webhook) SendFile ¶
func (w *Webhook) SendFile(file []byte, filename string, message *WebhookMessage) (response []byte, err error)
SendFile sends file with message to webhook
func (*Webhook) SendMessage ¶
func (w *Webhook) SendMessage(message *WebhookMessage) (response []byte, err error)
SendMessage sends message to webhook
type WebhookMessage ¶
type WebhookMessage struct { // Content is a message body up to 2000 characters. Content string `json:"content"` Username string `json:"username"` AvatarURL string `json:"avatar_url"` TTS bool `json:"tts"` Embeds []*Embed `json:"embeds"` }
WebhookMessage represents a message to send using webhook. When sending a message there must be one of content or embeds.
type WebhookType ¶
type WebhookType int
WebhookType is a webhook type for discord webhooks https://discordapp.com/developers/docs/resources/webhook#webhook-object-webhook-types
const ( // Incoming type Webhooks can post messages to channels with a generated token Incoming WebhookType = iota + 1 // ChannelFollower type Webhooks are internal webhooks used with Channel Following // to post new messages into channels ChannelFollower )
type WebhookUpdate ¶
type WebhookUpdate struct { Name string `json:"name"` // Avatar is a base64 encoded image. https://discordapp.com/developers/docs/reference#image-data Avatar string `json:"avatar"` }
WebhookUpdate is used to update webhooks using tokens.