Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrParseWebhook = errors.New("failed to parse discord webhook url")
ErrParseWebhook represents error when parsing url, id, or token
Functions ¶
This section is empty.
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://discord.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 *EmbedImage `json:"thumbnail"` Video *EmbedVideo `json:"video"` Author *EmbedAuthor `json:"author"` Fields []*EmbedField `json:"fields"` }
Embed represents discord embed. https://discord.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"` }
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 (max. 25)
type EmbedFooter ¶
EmbedFooter represents embed's footer
type EmbedImage ¶
type EmbedImage struct { // URL source of image (only supports http(s) and attachments) URL string `json:"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 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 Message ¶
type Message 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"` }
Message represents a message to send using webhook. When sending a message there must be one of content or embeds.
type Update ¶
type Update struct { Name string `json:"name"` // Avatar is a base64 encoded image. https://discord.com/developers/docs/reference#image-data Avatar string `json:"avatar"` }
Update is used to update webhooks using tokens. Only name and avatar can be updated.
type Webhook ¶
type Webhook struct { ID string `json:"id"` 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 FromIDAndToken ¶
FromIDAndToken parses id and token and returns Webhook struct.
func (*Webhook) Get ¶
Get gets information about webhook. Useful to get name, guild and channel IDs etc.
func (*Webhook) SendMessage ¶
SendMessage sends message to webhook