events

package
v0.2.22 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package events defines the WebSocket opcodes and dispatch event types used by the Uncord gateway protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DispatchEvent

type DispatchEvent string

DispatchEvent identifies the type of a gateway dispatch event. Each constant corresponds to a specific real-time event delivered over the WebSocket connection.

const (
	// Ready is sent after a successful identify, containing initial state.
	Ready DispatchEvent = "READY"
	// Resumed is sent after a successful session resume.
	Resumed DispatchEvent = "RESUMED"

	// MessageCreate is sent when a message is created in a channel.
	MessageCreate DispatchEvent = "MESSAGE_CREATE"
	// MessageUpdate is sent when a message is edited.
	MessageUpdate DispatchEvent = "MESSAGE_UPDATE"
	// MessageDelete is sent when a message is deleted.
	MessageDelete DispatchEvent = "MESSAGE_DELETE"

	// ChannelCreate is sent when a channel is created.
	ChannelCreate DispatchEvent = "CHANNEL_CREATE"
	// ChannelUpdate is sent when a channel is edited.
	ChannelUpdate DispatchEvent = "CHANNEL_UPDATE"
	// ChannelDelete is sent when a channel is deleted.
	ChannelDelete DispatchEvent = "CHANNEL_DELETE"

	// MemberAdd is sent when a user joins the server.
	MemberAdd DispatchEvent = "MEMBER_ADD"
	// MemberUpdate is sent when a member's roles or nickname change.
	MemberUpdate DispatchEvent = "MEMBER_UPDATE"
	// MemberRemove is sent when a member leaves or is removed.
	MemberRemove DispatchEvent = "MEMBER_REMOVE"

	// RoleCreate is sent when a role is created.
	RoleCreate DispatchEvent = "ROLE_CREATE"
	// RoleUpdate is sent when a role is edited.
	RoleUpdate DispatchEvent = "ROLE_UPDATE"
	// RoleDelete is sent when a role is deleted.
	RoleDelete DispatchEvent = "ROLE_DELETE"

	// PresenceUpdate is sent when a user's online status changes.
	PresenceUpdate DispatchEvent = "PRESENCE_UPDATE"
	// TypingStart is sent when a user begins typing in a channel.
	TypingStart DispatchEvent = "TYPING_START"
	// TypingStop is sent when a user stops typing in a channel, either explicitly or because a message was sent.
	TypingStop DispatchEvent = "TYPING_STOP"

	// MessageAck is sent when a user acknowledges messages in a channel, updating their read position.
	MessageAck DispatchEvent = "MESSAGE_ACK"

	// ReactionAdd is sent when a reaction is added to a message.
	ReactionAdd DispatchEvent = "REACTION_ADD"
	// ReactionRemove is sent when a reaction is removed from a message.
	ReactionRemove DispatchEvent = "REACTION_REMOVE"

	// ThreadCreate is sent when a thread is created.
	ThreadCreate DispatchEvent = "THREAD_CREATE"
	// ThreadUpdate is sent when a thread is edited.
	ThreadUpdate DispatchEvent = "THREAD_UPDATE"
	// ThreadDelete is sent when a thread is deleted.
	ThreadDelete DispatchEvent = "THREAD_DELETE"

	// DMChannelCreate is sent when a DM channel is created.
	DMChannelCreate DispatchEvent = "DM_CHANNEL_CREATE"
	// DMMessageCreate is sent when a message is created in a DM channel.
	DMMessageCreate DispatchEvent = "DM_MESSAGE_CREATE"
	// DMMessageUpdate is sent when a message is edited in a DM channel.
	DMMessageUpdate DispatchEvent = "DM_MESSAGE_UPDATE"
	// DMMessageDelete is sent when a message is deleted in a DM channel.
	DMMessageDelete DispatchEvent = "DM_MESSAGE_DELETE"

	// KeyBundleLow is sent when a device's one-time pre-key supply falls below the configured threshold.
	KeyBundleLow DispatchEvent = "KEY_BUNDLE_LOW"
	// IdentityKeyChanged is sent to DM peers when a user registers a new device or replaces an identity key.
	IdentityKeyChanged DispatchEvent = "IDENTITY_KEY_CHANGED"

	// InviteCreate is sent when an invite is created.
	InviteCreate DispatchEvent = "INVITE_CREATE"
	// InviteDelete is sent when an invite is revoked or expires.
	InviteDelete DispatchEvent = "INVITE_DELETE"

	// WebhookUpdate is sent when a webhook is created, edited, or deleted.
	WebhookUpdate DispatchEvent = "WEBHOOK_UPDATE"
	// EmojiUpdate is sent when custom emoji are added, edited, or removed.
	EmojiUpdate DispatchEvent = "EMOJI_UPDATE"
	// ServerUpdate is sent when server settings change.
	ServerUpdate DispatchEvent = "SERVER_UPDATE"
	// SlashCommandInvocation is sent when a slash command is invoked.
	SlashCommandInvocation DispatchEvent = "SLASH_COMMAND_INVOCATION"
)

type Frame added in v0.2.8

type Frame struct {
	Op   Opcode          `json:"op"`
	Seq  *int64          `json:"s,omitempty"`
	Type *DispatchEvent  `json:"t,omitempty"`
	Data json.RawMessage `json:"d,omitempty"`
}

Frame is the wire-format structure for all WebSocket messages. Dispatch events (op 0) carry a sequence number and event type; control frames use only op and optionally d.

type Opcode

type Opcode int

Opcode identifies the type of a WebSocket frame. The gateway uses opcodes to distinguish control frames (heartbeat, identify) from dispatch events that carry application data.

const (
	// OpcodeDispatch delivers a dispatch event (server → client).
	OpcodeDispatch Opcode = 0
	// OpcodeHeartbeat is a keep-alive ping (bidirectional).
	OpcodeHeartbeat Opcode = 1
	// OpcodeIdentify authenticates a new connection (client → server).
	OpcodeIdentify Opcode = 2
	// OpcodePresenceUpdate sets the client's presence status (client → server).
	OpcodePresenceUpdate Opcode = 3
	// OpcodeResume resumes a dropped session (client → server).
	OpcodeResume Opcode = 6
	// OpcodeReconnect asks the client to reconnect (server → client).
	OpcodeReconnect Opcode = 7
	// OpcodeInvalidSession tells the client its session is invalid (server → client).
	OpcodeInvalidSession Opcode = 9
	// OpcodeHello is sent on connect with the heartbeat interval (server → client).
	OpcodeHello Opcode = 10
	// OpcodeHeartbeatACK acknowledges a heartbeat (server → client).
	OpcodeHeartbeatACK Opcode = 11
)

Jump to

Keyboard shortcuts

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