/
gateway.ts
350 lines (333 loc) · 9.21 KB
/
gateway.ts
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/**
* Types extracted from https://discord.com/developers/docs/topics/gateway
*/
import type { Snowflake } from '../../globals';
import type { APIEmoji } from './emoji';
import type { APIUser } from './user';
/**
* https://discord.com/developers/docs/topics/gateway#get-gateway
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface APIGatewayInfo {
/**
* The WSS URL that can be used for connecting to the gateway
*/
url: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#get-gateway-bot
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface APIGatewayBotInfo extends APIGatewayInfo {
/**
* The recommended number of shards to use when connecting
*
* See https://discord.com/developers/docs/topics/gateway#sharding
*/
shards: number;
/**
* Information on the current session start limit
*
* See https://discord.com/developers/docs/topics/gateway#session-start-limit-object
*/
session_start_limit: APIGatewaySessionStartLimit;
}
/**
* https://discord.com/developers/docs/topics/gateway#session-start-limit-object
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface APIGatewaySessionStartLimit {
/**
* The total number of session starts the current user is allowed
*/
total: number;
/**
* The remaining number of session starts the current user is allowed
*/
remaining: number;
/**
* The number of milliseconds after which the limit resets
*/
reset_after: number;
/**
* The number of identify requests allowed per 5 seconds
*/
max_concurrency: number;
}
/**
* https://discord.com/developers/docs/topics/gateway#presence-update-presence-update-event-fields
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface GatewayPresenceUpdate {
/**
* The user presence is being updated for
*
* **The user object within this event can be partial, the only field which must be sent is the `id` field,
* everything else is optional.**
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
user: Partial<APIUser> & Pick<APIUser, 'id'>;
/**
* ID of the guild
*/
guild_id: Snowflake;
/**
* Either "idle", "dnd", "online", or "offline"
*/
status?: PresenceUpdateStatus;
/**
* User's current activities
*
* See https://discord.com/developers/docs/topics/gateway#activity-object
*/
activities?: GatewayActivity[];
/**
* User's platform-dependent status
*
* See https://discord.com/developers/docs/topics/gateway#client-status-object
*/
client_status?: GatewayPresenceClientStatus;
}
/**
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export enum PresenceUpdateStatus {
Online = 'online',
DoNotDisturb = 'dnd',
Idle = 'idle',
/**
* Invisible and shown as offline
*/
Invisible = 'invisible',
Offline = 'offline',
}
/**
* https://discord.com/developers/docs/topics/gateway#client-status-object
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface GatewayPresenceClientStatus {
/**
* The user's status set for an active desktop (Windows, Linux, Mac) application session
*/
desktop?: PresenceUpdateStatus;
/**
* The user's status set for an active mobile (iOS, Android) application session
*/
mobile?: PresenceUpdateStatus;
/**
* The user's status set for an active web (browser, bot account) application session
*/
web?: PresenceUpdateStatus;
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface GatewayActivity {
/**
* The activity's id
*/
id: string;
/**
* The activity's name
*/
name: string;
/**
* Activity type
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
*/
type: ActivityType;
/**
* Stream url, is validated when type is `1`
*/
url?: string | null;
/**
* Unix timestamp of when the activity was added to the user's session
*/
created_at: number;
/**
* Unix timestamps for start and/or end of the game
*/
timestamps?: GatewayActivityTimestamps;
sync_id?: string;
platform?: ActivityPlatform;
/**
* Application id for the game
*/
application_id?: Snowflake;
/**
* What the player is currently doing
*/
details?: string | null;
/**
* The user's current party status
*/
state?: string | null;
/**
* The emoji used for a custom status
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji
*/
emoji?: GatewayActivityEmoji;
session_id?: string;
/**
* Information for the current party of the player
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-party
*/
party?: GatewayActivityParty;
/**
* Images for the presence and their hover texts
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets
*/
assets?: GatewayActivityAssets;
/**
* Secrets for Rich Presence joining and spectating
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets
*/
secrets?: GatewayActivitySecrets;
/**
* Whether or not the activity is an instanced game session
*/
instance?: boolean;
/**
* Activity flags `OR`d together, describes what the payload includes
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
flags?: ActivityFlags;
/**
* The custom buttons shown in the Rich Presence (max 2)
*/
buttons?: GatewayActivityButton[] | string[];
}
/**
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export enum ActivityPlatform {
Desktop = 'desktop',
Samsung = 'samsung',
Xbox = 'xbox',
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export enum ActivityType {
/**
* Playing {game}
*/
Playing,
/**
* Streaming {details}
*/
Streaming,
/**
* Listening to {name}
*/
Listening,
/**
* Watching {details}
*/
Watching,
/**
* {emoji} {details}
*/
Custom,
/**
* Competing in {name}
*/
Competing,
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface GatewayActivityTimestamps {
/**
* Unix time (in milliseconds) of when the activity started
*/
start?: number;
/**
* Unix time (in milliseconds) of when the activity ends
*/
end?: number;
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export type GatewayActivityEmoji = Partial<Pick<APIEmoji, 'animated' | 'id'>> & Pick<APIEmoji, 'name'>;
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-party
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface GatewayActivityParty {
/**
* The id of the party
*/
id?: string;
/**
* Used to show the party's current and maximum size
*/
size?: [current_size: number, max_size: number];
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export type GatewayActivityAssets = Partial<
Record<'large_image' | 'large_text' | 'small_image' | 'small_text', string>
>;
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export type GatewayActivitySecrets = Partial<Record<'join' | 'match' | 'spectate', string>>;
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags
*
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export enum ActivityFlags {
Instance = 1 << 0,
Join = 1 << 1,
Spectate = 1 << 2,
JoinRequest = 1 << 3,
Sync = 1 << 4,
Play = 1 << 5,
PartyPrivacyFriends = 1 << 6,
PartyPrivacyVoiceChannel = 1 << 7,
Embedded = 1 << 8,
}
/**
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
*/
export interface GatewayActivityButton {
/**
* The text shown on the button (1-32 characters)
*/
label: string;
/**
* The url opened when clicking the button (1-512 characters)
*/
url: string;
}