Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Token is the string used for authenticating against Discord's websocket Token string // Prefix is the value to prefix commands so they are recognised Prefix string )
Functions ¶
func StartBot ¶
func StartBot()
StartBot gets the environment variables needed for the Discord gateway, creates the new session type and starts the initial websocket connection to Discord's gateway
func StartSubscriber ¶
func StartSubscriber()
StartSubscriber subscribes to the discord message_create event on the queue and waits for a response, also subscribes to the internal send_response event which then sends the payload to Discord's API
Types ¶
type APIEmbedPayload ¶
APIEmbedPayload is a payload for sending an embed based message over Discord's API
type APIPayload ¶
APIPayload is a payload for sending a text based message over Discord's API
func (*APIPayload) Prepare ¶
func (p *APIPayload) Prepare(content, channel string) error
Prepare is a helper command for formatting the message to an APIPayload type
type Message ¶
type Message struct { ID string `json:"id,omitempty"` // id of the message ChannelID string `json:"channel_id,omitempty"` // id of the channel the message was sent in GuildID string `json:"guild_id,omitempty"` // (?) id of the guild the message was sent in Content string `json:"content,omitempty"` // contents of the message SentAt Timestamp `json:"timestamp,omitempty"` // ISO8601 timestamp when this message was sent EditedAt Timestamp `json:"edited_timestamp,omitempty"` // (?) ISO8601 timestamp when this message was edited (or null if never) TTS bool `json:"tts,omitempty"` // boolean whether this was a TTS message MentionEveryone bool `json:"mention_everyone,omitempty"` // boolean whether this message mentions everyone MentionedRoles []string `json:"mention_roles,omitempty"` // array of role object ids - roles specifically mentioned in this message Pinned bool `json:"pinned,omitempty"` // boolean whether this message is pinned WebhookID string `json:"webhook_id,omitempty"` // (?) snowflake if the message is generated by a webhook, this is the webhook's id Type int `json:"type,omitempty"` // integer type of message Embed interface{} `json:"embed,omitempty"` // array of embed objects any embedded content }
Message is Discord's message structure
type Payload ¶
type Payload struct { OPCode int `json:"op"` Data json.RawMessage `json:"d"` Sequence int `json:"s,omitempty"` Event string `json:"t,omitempty"` }
Payload is a simple structure used to receive and send events over the websocket