packet

package
v0.0.0-...-9e75793 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	OpDispatch            = 0
	OpHeartbeat           = 1
	OpIdentify            = 2
	OpPresenceUpdate      = 3
	OpVoiceStateUpdate    = 4
	OpResume              = 6
	OpReconnect           = 7
	OpRequestGuildMembers = 8
	OpInvalidSession      = 9
	OpHello               = 10
	OpHeartbeatAck        = 11

	OpVoiceIdentify           = 0
	OpVoiceSelectProtocol     = 1
	OpVoiceReady              = 2
	OpVoiceHeartbeat          = 3
	OpVoiceSessionDescription = 4
	OpVoiceSpeaking           = 5
	OpVoiceHeartbeatAck       = 6
	OpVoiceResume             = 7
	OpVoiceHello              = 8
	OpVoiceResumed            = 9
	OpVoiceClientDisconnect   = 13
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CloseEventCode

type CloseEventCode int
const (
	CloseEventCodeUnknownError CloseEventCode = iota + 4000
	CloseEventCodeUnknownOpcode
	CloseEventCodeDecodeError
	CloseEventCodeNotAuthenticated
	CloseEventCodeAuthenticationFailed
	CloseEventCodeAlreadyAuthenticated

	CloseEventCodeInvalidSeq
	CloseEventCodeRateLimited
	CloseEventCodeSessionTimedOut
	CloseEventCodeInvalidShard
	CloseEventCodeShardingRequired
	CloseEventCodeInvalidAPIVersion
	CloseEventCodeInvalidIntents
	CloseEventCodeDisallowedIntents
)

func (CloseEventCode) ShouldReconnect

func (c CloseEventCode) ShouldReconnect() bool

type ConnectionProperties

type ConnectionProperties struct {
	Os      string `json:"$os,omitempty"`
	Browser string `json:"$browser,omitempty"`
	Device  string `json:"$device,omitempty"`
}

type GuildRequestMembers

type GuildRequestMembers struct {
	Packet
	Data struct {
		GuildId   string   `json:"guild_id"`            // ID of the guild to get members for
		Query     string   `json:"query,omitempty"`     // string that username starts with, or an empty string to return all members
		Limit     int      `json:"limit"`               // max number of members to send matching the query; a limit of 0 can be used with an empty string query to return all members
		Presences bool     `json:"presences,omitempty"` // used to specify if we want the presences of the matched members
		UserIds   []string `json:"user_ids,omitempty"`  // used to specify which users you wish to fetch
		Nonce     string   `json:"nonce,omitempty"`     // the nonce to identify the Guild Members Chunk response
	} `json:"d"`
}

type Heartbeat

type Heartbeat struct {
	Packet
	Data int64 `json:"d"`
}

func NewHeartbeat

func NewHeartbeat(lastSequence int64) *Heartbeat

type Hello

type Hello struct {
	*Packet
	Data struct {
		HeartbeatInterval time.Duration `json:"heartbeat_interval"`
	} `json:"d"`
}

func NewHello

func NewHello(data []byte) (*Hello, error)

type Identify

type Identify struct {
	Packet
	Data struct {
		Token          string                `json:"token"`
		Properties     *ConnectionProperties `json:"properties"`
		Compress       bool                  `json:"compress,omitempty"`
		LargeThreshold int                   `json:"large_threshold,omitempty"`
		Shard          []int                 `json:"shard,omitempty"`
		Presence       *PresenceUpdate       `json:"presence,omitempty"`
		Intents        int                   `json:"intents,omitempty"`
	} `json:"d,omitempty"`
}

func NewIdentify

func NewIdentify(token string, intents int) *Identify

type Packet

type Packet struct {
	Opcode   int             `json:"op"`
	Sequence int64           `json:"s,omitempty"`
	Event    string          `json:"t,omitempty"`
	Data     json.RawMessage `json:"d"`
}

func NewPacket

func NewPacket(data []byte) (*Packet, error)

type PresenceUpdate

type PresenceUpdate struct {
	Packet
	Data struct {
		Since      int                  `json:"since"`
		Activities [1]*discord.Activity `json:"activities"`
		Status     discord.StatusType   `json:"status"`
		AFK        bool                 `json:"afk"`
	} `json:"d"`
}

func NewPresenceUpdate

func NewPresenceUpdate(activity *discord.Activity, status discord.StatusType) *PresenceUpdate

type Resume

type Resume struct {
	Packet
	Data struct {
		Token     string `json:"token"`
		SessionID string `json:"session_id"`
		Sequence  int64  `json:"seq"`
	} `json:"d,omitempty"`
}

func NewResume

func NewResume(token, sessionID string, sequence int64) *Resume

type SpeakingFlag

type SpeakingFlag uint64
const (
	NotSpeaking SpeakingFlag = 0
	Microphone  SpeakingFlag = 1 << iota
	Soundshare
	Priority
)

type VoiceHeartbeat

type VoiceHeartbeat struct {
	Packet
	Data int64 `json:"d"`
}

func NewVoiceHeartbeat

func NewVoiceHeartbeat(data int64) *VoiceHeartbeat

type VoiceHello

type VoiceHello struct {
	Packet
	Data struct {
		HeartbeatInterval float64 `json:"heartbeat_interval"`
	} `json:"d,omitempty"`
}

type VoiceIdentify

type VoiceIdentify struct {
	Packet
	Data struct {
		ServerId  string `json:"server_id"`
		UserID    string `json:"user_id"`
		SessionId string `json:"session_id"`
		Token     string `json:"token"`
	} `json:"d,omitempty"`
}

func NewVoiceIdentify

func NewVoiceIdentify(serverId, userId, sessionId, token string) *VoiceIdentify

type VoiceReady

type VoiceReady struct {
	Packet
	Data struct {
		SSRC  uint32   `json:"ssrc"`
		IP    string   `json:"ip"`
		Port  int      `json:"port"`
		Modes []string `json:"modes"`
	} `json:"d"`
}

type VoiceResume

type VoiceResume struct {
	Packet
	Data struct {
		ServerId  string `json:"server_id"`
		SessionId string `json:"session_id"`
		Token     string `json:"token"`
	} `json:"d,omitempty"`
}

func NewVoiceResume

func NewVoiceResume(serverId, sessionId, token string) *VoiceResume

type VoiceSelectProtocol

type VoiceSelectProtocol struct {
	Packet
	Data struct {
		Protocol string `json:"protocol"`
		Data     struct {
			Address string `json:"address"`
			Port    uint16 `json:"port"`
			Mode    string `json:"mode"` // always "xsalsa20_poly1305"
		} `json:"data"`
	} `json:"d,omitempty"`
}

func NewVoiceSelectProtocol

func NewVoiceSelectProtocol(address string, port uint16) *VoiceSelectProtocol

type VoiceSessionDescription

type VoiceSessionDescription struct {
	Packet
	Data struct {
		Mode      string   `json:"mode"`
		SecretKey [32]byte `json:"secret_key"`
	} `json:"d,omitempty"`
}

type VoiceSpeaking

type VoiceSpeaking struct {
	Packet
	Data struct {
		Speaking SpeakingFlag `json:"speaking"`
		Delay    int          `json:"delay"`
		SSRC     uint32       `json:"ssrc"`
		UserId   string       `json:"user_id,omitempty"`
	} `json:"d"`
}

func NewVoiceSpeaking

func NewVoiceSpeaking(speaking bool, ssrc uint32) *VoiceSpeaking

type VoiceStateUpdate

type VoiceStateUpdate struct {
	Packet
	Data struct {
		GuildId   *string `json:"guild_id"`
		ChannelId *string `json:"channel_id"`
		SelfMute  bool    `json:"self_mute"`
		SelfDeaf  bool    `json:"self_deaf"`
	} `json:"d,omitempty"`
}

func NewVoiceStateUpdate

func NewVoiceStateUpdate(guildId, channelId string, selfMuted, selfDeaf bool) *VoiceStateUpdate

Jump to

Keyboard shortcuts

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