dishook

package module
v0.0.0-...-e45eb21 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllowedMentionEveryone = "everyone"
	AllowedMentionRoles    = "roles"
	AllowedMentionUsers    = "users"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Embed

type Embed struct {
	Title       string       `json:"title,omitempty"`
	Description string       `json:"description,omitempty"`
	URL         string       `json:"url,omitempty"`
	Timestamp   string       `json:"timestamp,omitempty"`
	Color       int          `json:"color,omitempty"`
	Footer      EmbedFooter  `json:"footer,omitempty"`
	Image       EmbedImage   `json:"image,omitempty"`
	Thumbnail   EmbedImage   `json:"thumbnail,omitempty"`
	Author      EmbedAuthor  `json:"author,omitempty"`
	Fields      []EmbedField `json:"fields,omitempty"`
}

Embed represents a Discord embed object that can be used as part of a Message. See more about specific fields at https://discord.com/developers/docs/resources/channel#embed-object-embed-structure

type EmbedAuthor

type EmbedAuthor struct {
	Name    string `json:"name,omitempty"`
	URL     string `json:"url,omitempty"`
	IconURL string `json:"icon_url,omitempty"`
}

EmbedAuthor represent a Discord embed author object that can be as part of a Message. See more about specific fields at https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure

type EmbedField

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

EmbedField represents a Discord embed field object that can be used as part of a Message. See more about specific fields at https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure

type EmbedFooter

type EmbedFooter struct {
	Text    string `json:"text"`
	IconURL string `json:"icon_url,omitempty"`
}

EmbedFooter represents an embed footer object that can be used as part of a message. See more about specific fields at https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure

type EmbedImage

type EmbedImage struct {
	URL string `json:"url,omitempty"`
}

EmbedImage represents an embed image object that can be used as part of a Message. See more about specific fields at https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure

type File

type File struct {
	Name    string
	Content []byte
}

File represents a file that can be send with in a Message

type Message

type Message struct {
	Content         string  `json:"content,omitempty"`
	Username        string  `json:"username,omitempty"`
	AvatarURL       string  `json:"avatar_url,omitempty"`
	TTS             bool    `json:"tts,omitempty"`
	Files           []File  `json:"-"`
	Embeds          []Embed `json:"embeds,omitempty"`
	AllowedMentions struct {
		Parse       []string `json:"parse,omitempty"`
		Roles       []string `json:"roles,omitempty"`
		Users       []string `json:"users,omitempty"`
		RepliedUser bool     `json:"replied_user,omitempty"`
	} `json:"allowed_mentions,omitempty"`
}

Message represents a message to be sent using a webhook. See information about specific fields at https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params. It also includes the allowed_mentions attribute, which represents a Discord Allowed Mentions object. See information about specific fields at https://discord.com/developers/docs/resources/channel#allowed-mentions-object.

func NewMessage

func NewMessage() *Message

NewMessage creates a new webhook message.

func (*Message) AddFile

func (s *Message) AddFile(filename string) (File, error)

AddFile takes a filename, reads the contents of that file and adds that file to the message

func (*Message) Send

func (s *Message) Send(endpoint string, wait bool) (*http.Response, error)

Send sends the Message object to the specified endpoint. The `wait` parameter will specify that the Discord API should wait for confirmation of the message being sent before a HTTP response is sent, which will contain the created message body. Returns the raw HTTP response, and an error. In the event that an error is returned after a request has been made to the Discord API, the response is also returned. Else, nil is returned.

type RatelimitError

type RatelimitError struct {
	RetryAt    time.Time `json:"-"`
	RetryAfter float64   `json:"retry_after"`
}

RatelimitError is used when a request was sent to the Discord API that caused a 429 error response to be returned.

func (*RatelimitError) Error

func (s *RatelimitError) Error() string

Error returns a string representation of the error

type RequestError

type RequestError struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

RequestError is used when a request was sent to the Discord API that caused a non-2xx and a non-429 response to be returned.

func (*RequestError) Error

func (s *RequestError) Error() string

Error returns a string representation of the error

type ValidationError

type ValidationError struct {
	// contains filtered or unexported fields
}

ValidationError is used when a Message object fails local validation

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error returns a string representation of the error

Jump to

Keyboard shortcuts

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