gateway

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package gateway handles the Gateway API of Discord

Index

Constants

This section is empty.

Variables

View Source
var ErrClientAlreadyConnected = errors.New("client is already connected to the gateway")

Functions

This section is empty.

Types

type ApplicationCommandPermissionsUpdate

type ApplicationCommandPermissionsUpdate struct {
	discord.GuildApplicationCommandPermissions
}

ApplicationCommandPermissionsUpdate is the data of the Application Command Permissions Update event https://discord.com/developers/docs/topics/gateway-events#application-command-permissions-update

type AutoModerationActionExecution

type AutoModerationActionExecution struct {
	GuildID              discord.Snowflake                 `json:"guild_id"`
	Action               discord.AutoModerationAction      `json:"action"`
	RuleID               discord.Snowflake                 `json:"rule_id"`
	RuleTriggerType      discord.AutoModerationTriggerType `json:"rule_trigger_type"`
	UserID               discord.Snowflake                 `json:"user_id"`
	ChannelID            discord.Snowflake                 `json:"channel_id,omitempty"`
	MessageID            discord.Snowflake                 `json:"message_id,omitempty"`
	AlertSystemMessageID discord.Snowflake                 `json:"alert_system_message_id,omitempty"`
	Content              string                            `json:"content"`
	MatchedKeyword       string                            `json:"matched_keyword,omitempty"`
	MatchedContent       string                            `json:"matched_content,omitempty"`
}

AutoModerationActionExecution is the data of the Auto Moderation Action Execution event https://discord.com/developers/docs/topics/gateway-events#auto-moderation-action-execution

type AutoModerationRuleCreate

type AutoModerationRuleCreate struct {
	discord.AutoModerationRule
}

AutoModerationRuleCreate is the data of the Auto Moderation Rule Create event https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-create

type AutoModerationRuleDelete

type AutoModerationRuleDelete struct {
	discord.AutoModerationRule
}

AutoModerationRuleDelete is the data of the Auto Moderation Rule Delete event https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-delete

type AutoModerationRuleUpdate

type AutoModerationRuleUpdate struct {
	discord.AutoModerationRule
}

AutoModerationRuleUpdate is the data of the Auto Moderation Rule Update event https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-update

type ChannelCreate

type ChannelCreate struct {
	discord.Channel
}

ChannelCreate is the data of the Channel Create event https://discord.com/developers/docs/topics/gateway-events#channel-create

type ChannelDelete

type ChannelDelete struct {
	discord.Channel
}

ChannelDelete is the data of the Channel Delete event https://discord.com/developers/docs/topics/gateway-events#channel-delete

type ChannelPinsUpdate

type ChannelPinsUpdate struct {
	GuildID          discord.Snowflake `json:"guild_id,omitempty"`
	ChannelID        discord.Snowflake `json:"channel_id"`
	LastPinTimestamp *time.Time        `json:"last_pin_timestamp,omitempty"`
}

ChannelPinsUpdate is the data of the Channel Pins Update event https://discord.com/developers/docs/topics/gateway-events#channel-pins-update

type ChannelUpdate

type ChannelUpdate struct {
	discord.Channel
}

ChannelUpdate is the data of the Channel Update event https://discord.com/developers/docs/topics/gateway-events#channel-update

type Client

type Client struct {
	Connection   *websocket.Conn
	LastSequence int64
	SessionID    string
	ResumeURL    string
	Logger       *tangra.Logger
	Debug        bool
	// contains filtered or unexported fields
}

Client is a client made to handle the Gateway API and REST API

func New

func New(token string, intents discord.Intents) *Client

New creates a new Gateway API and REST API client

func (*Client) Close

func (c *Client) Close()

Close closes the connection to Discord

func (*Client) CloseWithStatusCode

func (c *Client) CloseWithStatusCode(statusCode websocket.StatusCode, reason string)

CloseWithStatusCode closes the connection to Discord with a custom status code

func (*Client) Login

func (c *Client) Login() error

Login connects the client to the gateway

func (*Client) On

func (c *Client) On(eventType EventType, handlerFunction interface{})

On will listen to an event type and execute the given function when it is geting dispatched

func (*Client) Rest

func (c *Client) Rest() *rest.Client

Rest returns the REST client of the gateway client

func (*Client) Send

func (c *Client) Send(event EventSend) error

Send will send an event to the gateway

func (*Client) SetActivity

func (c *Client) SetActivity(statusType discord.StatusType, activityType discord.ActivityType, activity string) error

SetActivity sets the activity of the client connected to the gateway

func (*Client) SetRestClient

func (c *Client) SetRestClient(restClient *rest.Client)

SetRestClient sets the REST client of the gateway client

func (*Client) SetToken

func (c *Client) SetToken(token string)

SetToken sets the token header of the gateway client

type CloseCode

type CloseCode int

CloseCode represents a code sent when the connection is closed https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes

const (
	CloseCodeUnknownError CloseCode = 4000 + iota
	CloseCodeUnknownOpcode
	CloseCodeDecodeError
	CloseCodeNotAuthenticated
	CloseCodeAuthenticationFailed
	CloseCodeAlreadyAuthenticated

	CloseCodeInvalidSequence
	CloseCodeRateLimited
	CloseCodeSessionTimedOut
	CloseCodeInvalidShard
	CloseCodeShardingRequired
	CloseCodeInvalidAPIVersion
	CloseCodeInvalidIntents
	CloseCodeDisallowedIntents
)

func (CloseCode) ShouldReconnect

func (c CloseCode) ShouldReconnect() bool

ShouldReconnect returns whether the client should attempt a reconnection after the given close code (packets.CloseCode)

type ConnectionProperties

type ConnectionProperties struct {
	OS      string `json:"os"`
	Browser string `json:"browser"`
	Device  string `json:"device"`
}

ConnectionProperties represents properties about the client connecting

type Event

type Event struct {
	OpCode   OpCode          `json:"op"`
	Sequence int64           `json:"s"`
	Type     string          `json:"t"`
	Data     json.RawMessage `json:"d"`

	Struct interface{} `json:"-"`
}

Event is the structure of a gateway event https://discord.com/developers/docs/topics/gateway#gateway-events-example-gateway-event

func NewEvent

func NewEvent(message io.Reader) (*Event, error)

NewEvent parses a websocket message and returns a new event

type EventHandler

type EventHandler interface {
	Handle(*Client, interface{})
}

EventHandler is an interface for all the event handlers

type EventInterface

type EventInterface interface {
	New() interface{}
}

EventInterface is an interface for getting the interface of the event handler

type EventSend

type EventSend interface {
	GetOpCode() OpCode
}

EventSend is an interface that is implemented by all events that can be sent to the gateway

type EventType

type EventType string

EventType represents the event type

const (
	EventTypeReady                               EventType = "READY"
	EventTypeResumed                             EventType = "RESUMED"
	EventTypeApplicationCommandPermissionsUpdate EventType = "APPLICATION_COMMAND_PERMISSIONS_UPDATE"
	EventTypeAutoModerationRuleCreate            EventType = "AUTO_MODERATION_RULE_CREATE"
	EventTypeAutoModerationRuleUpdate            EventType = "AUTO_MODERATION_RULE_UPDATE"
	EventTypeAutoModerationRuleDelete            EventType = "AUTO_MODERATION_RULE_DELETE"
	EventTypeAutoModerationActionExecution       EventType = "AUTO_MODERATION_ACTION_EXECUTION"
	EventTypeChannelCreate                       EventType = "CHANNEL_CREATE"
	EventTypeChannelUpdate                       EventType = "CHANNEL_UPDATE"
	EventTypeChannelDelete                       EventType = "CHANNEL_DELETE"
	EventTypeChannelPinsUpdate                   EventType = "CHANNEL_PINS_UPDATE"
	EventTypeThreadCreate                        EventType = "THREAD_CREATE"
	EventTypeThreadUpdate                        EventType = "THREAD_UPDATE"
	EventTypeThreadDelete                        EventType = "THREAD_DELETE"
	EventTypeThreadListSync                      EventType = "THREAD_LIST_SYNC"
	EventTypeThreadMemberUpdate                  EventType = "THREAD_MEMBER_UPDATE"
	EventTypeThreadMembersUpdate                 EventType = "THREAD_MEMBERS_UPDATE"
	EventTypeGuildCreate                         EventType = "GUILD_CREATE"
	EventTypeGuildUpdate                         EventType = "GUILD_UPDATE"
	EventTypeGuildDelete                         EventType = "GUILD_DELETE"
	EventTypeGuildAuditLogEntryCreate            EventType = "GUILD_AUDIT_LOG_ENTRY_CREATE"
	EventTypeGuildBanAdd                         EventType = "GUILD_BAN_ADD"
	EventTypeGuildBanRemove                      EventType = "GUILD_BAN_REMOVE"
	EventTypeGuildEmojisUpdate                   EventType = "GUILD_EMOJIS_UPDATE"
	EventTypeGuildStickersUpdate                 EventType = "GUILD_STICKERS_UPDATE"
	EventTypeGuildIntegrationsUpdate             EventType = "GUILD_INTEGRATIONS_UPDATE"
	EventTypeGuildMemberAdd                      EventType = "GUILD_MEMBER_ADD"
	EventTypeGuildMemberRemove                   EventType = "GUILD_MEMBER_REMOVE"
	EventTypeGuildMemberUpdate                   EventType = "GUILD_MEMBER_UPDATE"
	EventTypeGuildMembersChunk                   EventType = "GUILD_MEMBERS_CHUNK"
	EventTypeGuildRoleCreate                     EventType = "GUILD_ROLE_CREATE"
	EventTypeGuildRoleUpdate                     EventType = "GUILD_ROLE_UPDATE"
	EventTypeGuildRoleDelete                     EventType = "GUILD_ROLE_DELETE"
	EventTypeGuildScheduledEventCreate           EventType = "GUILD_SCHEDULED_EVENT_CREATE"
	EventTypeGuildScheduledEventUpdate           EventType = "GUILD_SCHEDULED_EVENT_UPDATE"
	EventTypeGuildScheduledEventDelete           EventType = "GUILD_SCHEDULED_EVENT_DELETE"
	EventTypeGuildScheduledEventUserAdd          EventType = "GUILD_SCHEDULED_EVENT_USER_ADD"
	EventTypeGuildScheduledEventUserRemove       EventType = "GUILD_SCHEDULED_EVENT_USER_REMOVE"
	EventTypeIntegrationCreate                   EventType = "INTEGRATION_CREATE"
	EventTypeIntegrationUpdate                   EventType = "INTEGRATION_UPDATE"
	EventTypeIntegrationDelete                   EventType = "INTEGRATION_DELETE"
	EventTypeInteractionCreate                   EventType = "INTERACTION_CREATE"
	EventTypeInviteCreate                        EventType = "INVITE_CREATE"
	EventTypeInviteDelete                        EventType = "INVITE_DELETE"
	EventTypeMessageCreate                       EventType = "MESSAGE_CREATE"
	EventTypeMessageUpdate                       EventType = "MESSAGE_UPDATE"
	EventTypeMessageDelete                       EventType = "MESSAGE_DELETE"
	EventTypeMessageDeleteBulk                   EventType = "MESSAGE_DELETE_BULK"
	EventTypeMessageReactionAdd                  EventType = "MESSAGE_REACTION_ADD"
	EventTypeMessageReactionRemove               EventType = "MESSAGE_REACTION_REMOVE"
	EventTypeMessageReactionRemoveAll            EventType = "MESSAGE_REACTION_REMOVE_ALL"
	EventTypeMessageReactionRemoveEmoji          EventType = "MESSAGE_REACTION_REMOVE_EMOJI"
	EventTypePresenceUpdate                      EventType = "PRESENCE_UPDATE"
	EventTypeStageInstanceCreate                 EventType = "STAGE_INSTANCE_CREATE"
	EventTypeStageInstanceUpdate                 EventType = "STAGE_INSTANCE_UPDATE"
	EventTypeStageInstanceDelete                 EventType = "STAGE_INSTANCE_DELETE"
	EventTypeTypingStart                         EventType = "TYPING_START"
	EventTypeUserUpdate                          EventType = "USER_UPDATE"
	EventTypeVoiceStateUpdate                    EventType = "VOICE_STATE_UPDATE"
	EventTypeVoiceServerUpdate                   EventType = "VOICE_SERVER_UPDATE"
	EventTypeWebhooksUpdate                      EventType = "WEBHOOKS_UPDATE"
)

type GenericGuildBan

type GenericGuildBan struct {
	GuildID discord.Snowflake `json:"guild_id"`
	User    discord.User      `json:"user"`
}

GenericGuildBan is the common data of the Guild Ban Add/Remove events https://discord.com/developers/docs/topics/gateway-events#guild-ban-add https://discord.com/developers/docs/topics/gateway-events#guild-ban-remove

type GenericGuildRole

type GenericGuildRole struct {
	GuildID discord.Snowflake `json:"guild_id"`
	Role    discord.Role      `json:"role"`
}

GenericGuildRole is the common data of the Guild Role Create/Update events https://discord.com/developers/docs/topics/gateway-events#guild-role-create https://discord.com/developers/docs/topics/gateway-events#guild-role-update

type GenericGuildScheduledEventUser

type GenericGuildScheduledEventUser struct {
	GuildScheduledEventID discord.Snowflake `json:"guild_scheduled_event_id"`
	UserID                discord.Snowflake `json:"user_id"`
	GuildID               discord.Snowflake `json:"guild_id"`
}

GenericGuildScheduledEventUser is the common data of the Guild Scheduled Event User Add/Remove events https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-user-add https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-user-remove

type GenericIntegration

type GenericIntegration struct {
	discord.Integration
	GuildID discord.Snowflake `json:"guild_id"`
}

GenericIntegration is the common data of the Integration Create/Update events https://discord.com/developers/docs/topics/gateway-events#integration-create https://discord.com/developers/docs/topics/gateway-events#integration-update

type GenericMessage

type GenericMessage struct {
	discord.Message
	Member *discord.Member `json:"member,omitempty"`
}

GenericMessage is the common data of the Message Create/Update events https://discord.com/developers/docs/topics/gateway-events#message-create https://discord.com/developers/docs/topics/gateway-events#message-update

type GuildAuditLogEntryCreate

type GuildAuditLogEntryCreate struct {
	discord.AuditLogEntry
}

GuildAuditLogEntryCreate is the data of the Guild Audit Log Entry Create event https://discord.com/developers/docs/topics/gateway-events#guild-audit-log-entry-create

type GuildBanAdd

type GuildBanAdd struct {
	GenericGuildBan
}

GuildBanAdd is the data of the Guild Ban Add event https://discord.com/developers/docs/topics/gateway-events#guild-ban-add

type GuildBanRemove

type GuildBanRemove struct {
	GenericGuildBan
}

GuildBanRemove is the data of the Guild Ban Remove event https://discord.com/developers/docs/topics/gateway-events#guild-ban-remove

type GuildCreate

type GuildCreate struct {
	discord.Guild
	JoinedAt             time.Time                     `json:"joined_at"`
	Large                bool                          `json:"large"`
	Unavailable          bool                          `json:"unavailable,omitempty"`
	MemberCount          int                           `json:"member_count"`
	VoiceStates          []discord.VoiceState          `json:"voice_states"`
	Members              []discord.Member              `json:"members"`
	Channels             []discord.Channel             `json:"channels"`
	Threads              []discord.Channel             `json:"threads"`
	Presences            []PresenceUpdate              `json:"presences"`
	StageInstances       []discord.StageInstance       `json:"stage_instances"`
	GuildScheduledEvents []discord.GuildScheduledEvent `json:"guild_scheduled_events"`
}

GuildCreate is the data of the Guild Create event https://discord.com/developers/docs/topics/gateway-events#guild-create

type GuildDelete

type GuildDelete struct {
	discord.UnavailableGuild
}

GuildDelete is the data of the Guild Delete event https://discord.com/developers/docs/topics/gateway-events#guild-delete

type GuildEmojisUpdate

type GuildEmojisUpdate struct {
	GuildID discord.Snowflake `json:"guild_id"`
	Emojis  []discord.Emoji   `json:"emojis"`
}

GuildEmojisUpdate is the data of the Guild Emojis Update event https://discord.com/developers/docs/topics/gateway-events#guild-emojis-update

type GuildIntegrationsUpdate

type GuildIntegrationsUpdate struct {
	GuildID discord.Snowflake `json:"guild_id"`
}

GuildIntegrationsUpdate is the data of the Guild Integrations Update event https://discord.com/developers/docs/topics/gateway-events#guild-integrations-update

type GuildMemberAdd

type GuildMemberAdd struct {
	discord.Member
}

GuildMemberAdd is the data of the Guild Member Add event https://discord.com/developers/docs/topics/gateway-events#guild-member-add

type GuildMemberRemove

type GuildMemberRemove struct {
	GuildID discord.Snowflake `json:"guild_id"`
	User    discord.User      `json:"user"`
}

GuildMemberRemove is the data of the Guild Member Remove event https://discord.com/developers/docs/topics/gateway-events#guild-member-remove

type GuildMemberUpdate

type GuildMemberUpdate struct {
	GuildID                    discord.Snowflake       `json:"guild_id"`
	Roles                      discord.ArraySnowflakes `json:"roles"`
	User                       discord.User            `json:"user"`
	Nick                       string                  `json:"nick,omitempty"`
	Avatar                     string                  `json:"avatar,omitempty"`
	JoinedAt                   *time.Time              `json:"joined_at,omitempty"`
	PremiumSince               *time.Time              `json:"premium_since,omitempty"`
	Deaf                       bool                    `json:"deaf"`
	Mute                       bool                    `json:"mute"`
	Pending                    bool                    `json:"pending"`
	CommunicationDisabledUntil *time.Time              `json:"communication_disabled_until,omitempty"`
}

GuildMemberUpdate is the data of the Guild Member Update event https://discord.com/developers/docs/topics/gateway-events#guild-member-update

type GuildMembersChunk

type GuildMembersChunk struct {
	GuildID    discord.Snowflake       `json:"guild_id"`
	Members    []discord.Member        `json:"members"`
	ChunkIndex int                     `json:"chunk_index"`
	ChunkCount int                     `json:"chunk_count"`
	NotFound   discord.ArraySnowflakes `json:"not_found"`
	Presences  []PresenceUpdate        `json:"presences"`
	Nonce      string                  `json:"nonce"`
}

GuildMembersChunk is the data of the Guild Members Chunk event https://discord.com/developers/docs/topics/gateway-events#guild-members-chunk

type GuildRoleCreate

type GuildRoleCreate struct {
	GenericGuildRole
}

GuildRoleCreate is the data of the Guild Role Create event https://discord.com/developers/docs/topics/gateway-events#guild-role-create

type GuildRoleDelete

type GuildRoleDelete struct {
	GuildID discord.Snowflake `json:"guild_id"`
	RoleID  discord.Snowflake `json:"role_id"`
}

GuildRoleDelete is the data of the Guild Role Delete event https://discord.com/developers/docs/topics/gateway-events#guild-role-delete

type GuildRoleUpdate

type GuildRoleUpdate struct {
	GenericGuildRole
}

GuildRoleUpdate is the data of the Guild Role Update event https://discord.com/developers/docs/topics/gateway-events#guild-role-update

type GuildScheduledEventCreate

type GuildScheduledEventCreate struct {
	discord.GuildScheduledEvent
}

GuildScheduledEventCreate is the data of the Guild Scheduled Event Create event https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-create

type GuildScheduledEventDelete

type GuildScheduledEventDelete struct {
	discord.GuildScheduledEvent
}

GuildScheduledEventDelete is the data of the Guild Scheduled Event Delete event https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-delete

type GuildScheduledEventUpdate

type GuildScheduledEventUpdate struct {
	discord.GuildScheduledEvent
}

GuildScheduledEventUpdate is the data of the Guild Scheduled Event Update event https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-update

type GuildScheduledEventUserAdd

type GuildScheduledEventUserAdd struct {
	GenericGuildScheduledEventUser
}

GuildScheduledEventUserAdd is the data of the Guild Scheduled Event User Add event https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-user-add

type GuildScheduledEventUserRemove

type GuildScheduledEventUserRemove struct {
	GenericGuildScheduledEventUser
}

GuildScheduledEventUserRemove is the data of the Guild Scheduled Event User Remove event https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-user-remove

type GuildStickersUpdate

type GuildStickersUpdate struct {
	GuildID  discord.Snowflake `json:"guild_id"`
	Stickers []discord.Sticker `json:"stickers"`
}

GuildStickersUpdate is the data of the Guild Stickers Update event https://discord.com/developers/docs/topics/gateway-events#guild-stickers-update

type GuildUpdate

type GuildUpdate struct {
	discord.Guild
}

GuildUpdate is the data of the Guild Update event https://discord.com/developers/docs/topics/gateway-events#guild-update

type Heartbeat

type Heartbeat struct {
	OpCode   OpCode `json:"op"`
	Sequence int64  `json:"d"`
}

Heartbeat represents a heartbeat event that should be sent to the gateway to keep the connection alive https://discord.com/developers/docs/topics/gateway-events#heartbeat

func NewHeartbeatEvent

func NewHeartbeatEvent(sequence int64) *Heartbeat

NewHeartbeatEvent creates a new Heartbeat event

func (*Heartbeat) GetOpCode

func (e *Heartbeat) GetOpCode() OpCode

GetOpCode returns the OpCode of the event

type Hello

type Hello struct {
	HeartbeatInterval int `json:"heartbeat_interval"`
}

Hello is the data of the Hello event https://discord.com/developers/docs/topics/gateway-events#hello

type Identify

type Identify struct {
	OpCode OpCode       `json:"op"`
	Data   IdentifyData `json:"d"`
}

Identify represents the event to send to the gateway right after opening a connection https://discord.com/developers/docs/topics/gateway-events#identify

func NewIdentifyEvent

func NewIdentifyEvent(token string, properties ConnectionProperties, intents discord.Intents) Identify

NewIdentifyEvent creates a new Identify event

type IdentifyData

type IdentifyData struct {
	Token      string               `json:"token"`
	Properties ConnectionProperties `json:"properties"`
	Intents    discord.Intents      `json:"intents"`
}

IdentifyData represents the data to send when sending an Identify event

type IntegrationCreate

type IntegrationCreate struct {
	GenericIntegration
}

IntegrationCreate is the data of the Integration Create event https://discord.com/developers/docs/topics/gateway-events#integration-create

type IntegrationDelete

type IntegrationDelete struct {
	ID            discord.Snowflake `json:"id"`
	GuildID       discord.Snowflake `json:"guild_id"`
	ApplicationID discord.Snowflake `json:"application_id"`
}

IntegrationDelete is the data of the Integration Delete event https://discord.com/developers/docs/topics/gateway-events#integration-delete

type IntegrationUpdate

type IntegrationUpdate struct {
	GenericIntegration
}

IntegrationUpdate is the data of the Integration Update event https://discord.com/developers/docs/topics/gateway-events#integration-update

type InteractionCreate

type InteractionCreate struct {
	discord.Interaction
}

InteractionCreate is the data of the Interaction Create event https://discord.com/developers/docs/topics/gateway-events#interaction-create

type InviteCreate

type InviteCreate struct {
	ChannelID         discord.Snowflake        `json:"channel_id"`
	Code              string                   `json:"code"`
	CreatedAt         time.Time                `json:"created_at"`
	GuildID           discord.Snowflake        `json:"guild_id,omitempty"`
	Inviter           discord.User             `json:"inviter"`
	MaxAge            int                      `json:"max_age"`
	MaxUses           int                      `json:"max_uses"`
	TargetType        discord.InviteTargetType `json:"target_type"`
	TargetUser        *discord.User            `json:"target_user,omitempty"`
	TargetApplication *discord.Application     `json:"target_application,omitempty"`
	Temporary         bool                     `json:"temporary"`
	Uses              int                      `json:"uses"`
}

InviteCreate is the data of the Invite Create event https://discord.com/developers/docs/topics/gateway-events#invite-create

type InviteDelete

type InviteDelete struct {
	ChannelID discord.Snowflake `json:"channel_id"`
	GuildID   discord.Snowflake `json:"guild_id,omitempty"`
	Code      string            `json:"code"`
}

InviteDelete is the data of the Invite Delete event https://discord.com/developers/docs/topics/gateway-events#invite-delete

type MessageCreate

type MessageCreate struct {
	GenericMessage
}

MessageCreate is the data of the Message Create event https://discord.com/developers/docs/topics/gateway-events#message-create

type MessageDelete

type MessageDelete struct {
	ID        discord.Snowflake `json:"id"`
	ChannelID discord.Snowflake `json:"channel_id"`
	GuildID   discord.Snowflake `json:"guild_id,omitempty"`
}

MessageDelete is the data of the Message Delete event https://discord.com/developers/docs/topics/gateway-events#message-delete

type MessageDeleteBulk

type MessageDeleteBulk struct {
	IDs       discord.ArraySnowflakes `json:"ids"`
	ChannelID discord.Snowflake       `json:"channel_id"`
	GuildID   discord.Snowflake       `json:"guild_id,omitempty"`
}

MessageDeleteBulk is the data of the Message Delete Bulk event https://discord.com/developers/docs/topics/gateway-events#message-delete-bulk

type MessageReactionAdd

type MessageReactionAdd struct {
	GenericMessageReaction
	UserID          discord.Snowflake `json:"user_id"`
	Member          *discord.Member   `json:"member,omitempty"`
	Emoji           discord.Emoji     `json:"emoji"`
	MessageAuthorID discord.Snowflake `json:"message_author_id,omitempty"`
}

MessageReactionAdd is the data of the Message Reaction Add event https://discord.com/developers/docs/topics/gateway-events#message-reaction-add

type MessageReactionRemove

type MessageReactionRemove struct {
	GenericMessageReaction
	UserID discord.Snowflake `json:"user_id"`
	Emoji  discord.Emoji     `json:"emoji"`
}

MessageReactionRemove is the data of the Message Reaction Remove event https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove

type MessageReactionRemoveAll

type MessageReactionRemoveAll struct {
	GenericMessageReaction
}

MessageReactionRemoveAll is the data of the Message Reaction Remove All event https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove-all

type MessageReactionRemoveEmoji

type MessageReactionRemoveEmoji struct {
	GenericMessageReaction
	Emoji discord.Emoji `json:"emoji"`
}

MessageReactionRemoveEmoji is the data of the Message Reaction Remove Emoji event https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove-emoji

type MessageUpdate

type MessageUpdate struct {
	GenericMessage
}

MessageUpdate is the data of the Message Update event https://discord.com/developers/docs/topics/gateway-events#message-update

type OpCode

type OpCode int

OpCode represents operation codes from the Gateway API https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes

const (
	OpCodeDispatch OpCode = iota
	OpCodeHeartbeat
	OpCodeIdentify
	OpCodePresenceUpdate
	OpCodeVoiceStateUpdate

	OpCodeResume
	OpCodeReconnect
	OpCodeRequestGuildMembers
	OpCodeInvalidSession
	OpCodeHello
	OpCodeHeartbeatACK
)

type PresenceUpdate

type PresenceUpdate struct {
	User         discord.User         `json:"user"`
	GuildID      discord.Snowflake    `json:"guild_id"`
	Status       string               `json:"status"`
	Activities   []discord.Activity   `json:"activities"`
	ClientStatus discord.ClientStatus `json:"client_status"`
}

PresenceUpdate is the data of the Presence Update event https://discord.com/developers/docs/topics/gateway-events#presence-update

type Ready

type Ready struct {
	Version          int                        `json:"v"`
	User             *discord.User              `json:"user"`
	Guilds           []discord.UnavailableGuild `json:"guilds"`
	SessionID        string                     `json:"session_id"`
	ResumeGatewayURL string                     `json:"resume_gateway_url"`
	Shard            [2]int                     `json:"shard"`
	Application      discord.Application        `json:"application"`
}

Ready is the data of the Ready event https://discord.com/developers/docs/topics/gateway-events#ready-ready-event-fields

type RequestGuildMembers

type RequestGuildMembers struct {
	OpCode OpCode                  `json:"op"`
	Data   RequestGuildMembersData `json:"d"`
}

RequestGuildMembers represents the event to send to the gateway to receive all members for a guild or list of guilds https://discord.com/developers/docs/topics/gateway-events#request-guild-members

func NewRequestGuildMembersEvent

func NewRequestGuildMembersEvent(guildID discord.Snowflake, query string, limit int, presences bool, userIDs discord.ArraySnowflakes, nonce string) *RequestGuildMembers

NewRequestGuildMembersEvent creates a new Request Guild Members event

func (*RequestGuildMembers) GetOpCode

func (e *RequestGuildMembers) GetOpCode() OpCode

GetOpCode returns the OpCode of the event

type RequestGuildMembersData

type RequestGuildMembersData struct {
	GuildID   discord.Snowflake       `json:"guild_id"`
	Query     string                  `json:"query"`
	Limit     int                     `json:"limit"`
	Presences bool                    `json:"presences"`
	UserIDs   discord.ArraySnowflakes `json:"user_ids"`
	Nonce     string                  `json:"nonce"`
}

RequestGuildMembersData represents the data to send when sending a Request Guild Members event

type Resume

type Resume struct {
	OpCode OpCode     `json:"op"`
	Data   ResumeData `json:"d"`
}

Resume represents a resume event that should be sent to the gateway when wanting to resume a session https://discord.com/developers/docs/topics/gateway-events#resume

func NewResumeEvent

func NewResumeEvent(token, sessionID string, sequence int64) Resume

NewResumeEvent creates a new Resume event

type ResumeData

type ResumeData struct {
	Token     string `json:"token"`
	SessionID string `json:"session_id"`
	Sequence  int64  `json:"seq"`
}

ResumeData represents the data to send when sending a Resume event

type StageInstanceCreate

type StageInstanceCreate struct {
	discord.StageInstance
}

StageInstanceCreate is the data of the Stage Instance Create event https://discord.com/developers/docs/topics/gateway-events#stage-instance-create

type StageInstanceDelete

type StageInstanceDelete struct {
	discord.StageInstance
}

StageInstanceDelete is the data of the Stage Instance Delete event https://discord.com/developers/docs/topics/gateway-events#stage-instance-delete

type StageInstanceUpdate

type StageInstanceUpdate struct {
	discord.StageInstance
}

StageInstanceUpdate is the data of the Stage Instance Update event https://discord.com/developers/docs/topics/gateway-events#stage-instance-update

type ThreadCreate

type ThreadCreate struct {
	discord.Channel
}

ThreadCreate is the data of the Thread Create event https://discord.com/developers/docs/topics/gateway-events#thread-create

type ThreadDelete

type ThreadDelete struct {
	discord.Channel
}

ThreadDelete is the data of the Thread Delete event https://discord.com/developers/docs/topics/gateway-events#thread-delete

type ThreadListSync

type ThreadListSync struct {
	GuildID    discord.Snowflake       `json:"guild_id"`
	ChannelIDs discord.ArraySnowflakes `json:"channel_ids,omitempty"`
	Threads    []discord.Channel       `json:"threads"`
	Members    []discord.ThreadMember  `json:"members"`
}

ThreadListSync is the data of the Thread List Sync event https://discord.com/developers/docs/topics/gateway-events#thread-list-sync

type ThreadMemberUpdate

type ThreadMemberUpdate struct {
	discord.ThreadMember
	GuildID discord.Snowflake `json:"guild_id"`
}

ThreadMemberUpdate is the data of the Thread Member Update event https://discord.com/developers/docs/topics/gateway-events#thread-member-update

type ThreadMembersUpdate

type ThreadMembersUpdate struct {
	ID               discord.Snowflake       `json:"id"`
	GuildID          discord.Snowflake       `json:"guild_id"`
	MemberCount      int                     `json:"member_count"`
	AddedMembers     []discord.ThreadMember  `json:"added_members,omitempty"`
	RemovedMemberIDs discord.ArraySnowflakes `json:"removed_member_ids,omitempty"`
}

ThreadMembersUpdate is the data of the Thread Members Update event https://discord.com/developers/docs/topics/gateway-events#thread-members-update

type ThreadUpdate

type ThreadUpdate struct {
	discord.Channel
}

ThreadUpdate is the data of the Thread Update event https://discord.com/developers/docs/topics/gateway-events#thread-update

type TypingStart

type TypingStart struct {
	ChannelID discord.Snowflake `json:"channel_id"`
	GuildID   discord.Snowflake `json:"guild_id,omitempty"`
	UserID    discord.Snowflake `json:"user_id"`
	Timestamp int               `json:"timestamp"`
	Member    *discord.Member   `json:"member,omitempty"`
}

TypingStart is the data of the Typing Start event https://discord.com/developers/docs/topics/gateway-events#typing-start

type UpdatePresence

type UpdatePresence struct {
	OpCode OpCode             `json:"op"`
	Data   UpdatePresenceData `json:"d"`
}

UpdatePresence represents the event to send to the gateway when wanting to update the presence https://discord.com/developers/docs/topics/gateway-events#update-presence

func NewUpdatePresenceEvent

func NewUpdatePresenceEvent(since int, activities []discord.Activity, status discord.StatusType, afk bool) *UpdatePresence

NewUpdatePresenceEvent creates a new Update Presence event

func (*UpdatePresence) GetOpCode

func (e *UpdatePresence) GetOpCode() OpCode

GetOpCode returns the OpCode of the event

type UpdatePresenceData

type UpdatePresenceData struct {
	Since      int                `json:"since"`
	Activities []discord.Activity `json:"activities"`
	Status     discord.StatusType `json:"status"`
	AFK        bool               `json:"afk"`
}

UpdatePresenceData represents the data to send when sending an Update Presence event

type UpdateVoiceState

type UpdateVoiceState struct {
	OpCode OpCode               `json:"op"`
	Data   UpdateVoiceStateData `json:"d"`
}

UpdateVoiceState represents the event to send to the gateway when wanting to update the voice state https://discord.com/developers/docs/topics/gateway-events#update-voice-state

func NewUpdateVoiceStateEvent

func NewUpdateVoiceStateEvent(guildID, channelID discord.Snowflake, selfMute, selfDeaf bool) *UpdateVoiceState

NewUpdateVoiceStateEvent creates a new Update Voice State event

func (*UpdateVoiceState) GetOpCode

func (e *UpdateVoiceState) GetOpCode() OpCode

GetOpCode returns the OpCode of the event

type UpdateVoiceStateData

type UpdateVoiceStateData struct {
	GuildID   discord.Snowflake `json:"guild_id"`
	ChannelID discord.Snowflake `json:"channel_id,omitempty"`
	SelfMute  bool              `json:"self_mute"`
	SelfDeaf  bool              `json:"self_deaf"`
}

UpdateVoiceStateData represents the data to send when sending an Update Voice State event

type UserUpdate

type UserUpdate struct {
	discord.User
}

UserUpdate is the data of the User Update event https://discord.com/developers/docs/topics/gateway-events#user-update

type VoiceServerUpdate

type VoiceServerUpdate struct {
	Token    string            `json:"token"`
	GuildID  discord.Snowflake `json:"guild_id"`
	Endpoint string            `json:"endpoint"`
}

VoiceServerUpdate is the data of the Voice Server Update event https://discord.com/developers/docs/topics/gateway-events#voice-server-update

type VoiceStateUpdate

type VoiceStateUpdate struct {
	discord.VoiceState
}

VoiceStateUpdate is the data of the Voice State Update event https://discord.com/developers/docs/topics/gateway-events#voice-state-update

type WebhooksUpdate

type WebhooksUpdate struct {
	GuildID   discord.Snowflake `json:"guild_id"`
	ChannelID discord.Snowflake `json:"channel_id"`
}

WebhooksUpdate is the data of the Webhooks Update event https://discord.com/developers/docs/topics/gateway-events#webhooks-update

Jump to

Keyboard shortcuts

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