about summary refs log tree commit diff
path: root/pkg/discord/payloads.go
blob: 81c6c68cc40752d70d14cc1ecbe9802880beb569 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package discord

type GatewayOp uint8

const (
	GATEWAY_OP_DISPATCH              GatewayOp = 0
	GATEWAY_OP_HEARTBEAT             GatewayOp = 1
	GATEWAY_OP_IDENTIFY              GatewayOp = 2
	GATEWAY_OP_PRESENCE_UPDATE       GatewayOp = 3
	GATEWAY_OP_VOICE_STATE_UPDATE    GatewayOp = 4
	GATEWAY_OP_RESUME                GatewayOp = 6
	GATEWAY_OP_RECONNECT             GatewayOp = 7
	GATEWAY_OP_REQUEST_GUILD_MEMBERS GatewayOp = 8
	GATEWAY_OP_INVALID_SESSION       GatewayOp = 9
	GATEWAY_OP_HELLO                 GatewayOp = 10
	GATEWAY_OP_HEARTBEAT_ACK         GatewayOp = 11
)

type GatewayPayload[D any] struct {
	Op        GatewayOp `json:"op"`
	Data      D         `json:"d,omitempty"`
	Sequence  uint64    `json:"s,omitempty"`
	EventName string    `json:"t,omitempty"`
}

type GatewayIdentifyMsg struct {
	Token      string                    `json:"token"`
	Intents    uint64                    `json:"intents"`
	Properties GatewayIdentifyProperties `json:"properties"`
}

type GatewayHelloEvent struct {
	HeartbeatInterval uint64 `json:"heartbeat_interval"`
}

type GatewayReadyEvent struct {
	Version   uint64  `json:"v"`
	User      User    `json:"user"`
	Guilds    []Guild `json:"guilds"`
	SessionID string  `json:"session_id"`
	Shard     []int   `json:"shard"`
}

type GatewayMessageCreateEvent Message

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