cloudstorm 0.5.8 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,686 @@
1
- import Client from "./Client";
2
- import Constants from "./Constants";
3
- import Intents from "./Intents";
4
- export * from "./Types";
5
- export { Client, Constants, Intents };
6
- declare const _default: typeof import("./index");
7
- export default _default;
1
+ import * as discord_typings from 'discord-typings';
2
+ import * as snowtransfer from 'snowtransfer';
3
+ import * as events from 'events';
4
+ import { EventEmitter } from 'events';
5
+
6
+ type IntentFlags = typeof flags;
7
+ type IntentResolvable = number | Array<number> | keyof IntentFlags | Array<keyof IntentFlags>;
8
+ declare const flags: {
9
+ GUILDS: number;
10
+ GUILD_MEMBERS: number;
11
+ GUILD_BANS: number;
12
+ GUILD_EMOJIS_AND_STICKERS: number;
13
+ GUILD_INTEGRATIONS: number;
14
+ GUILD_WEBHOOKS: number;
15
+ GUILD_INVITES: number;
16
+ GUILD_VOICE_STATES: number;
17
+ GUILD_PRESENCES: number;
18
+ GUILD_MESSAGES: number;
19
+ GUILD_MESSAGE_REACTIONS: number;
20
+ GUILD_MESSAGE_TYPING: number;
21
+ DIRECT_MESSAGES: number;
22
+ DIRECT_MESSAGE_REACTIONS: number;
23
+ DIRECT_MESSAGE_TYPING: number;
24
+ MESSAGE_CONTENT: number;
25
+ GUILD_SCHEDULED_EVENTS: number;
26
+ };
27
+ declare function resolve(bit?: IntentResolvable): number;
28
+ declare const _default: {
29
+ flags: {
30
+ GUILDS: number;
31
+ GUILD_MEMBERS: number;
32
+ GUILD_BANS: number;
33
+ GUILD_EMOJIS_AND_STICKERS: number;
34
+ GUILD_INTEGRATIONS: number;
35
+ GUILD_WEBHOOKS: number;
36
+ GUILD_INVITES: number;
37
+ GUILD_VOICE_STATES: number;
38
+ GUILD_PRESENCES: number;
39
+ GUILD_MESSAGES: number;
40
+ GUILD_MESSAGE_REACTIONS: number;
41
+ GUILD_MESSAGE_TYPING: number;
42
+ DIRECT_MESSAGES: number;
43
+ DIRECT_MESSAGE_REACTIONS: number;
44
+ DIRECT_MESSAGE_TYPING: number;
45
+ MESSAGE_CONTENT: number;
46
+ GUILD_SCHEDULED_EVENTS: number;
47
+ };
48
+ privileged: number;
49
+ all: number;
50
+ non_privileged: number;
51
+ resolve: typeof resolve;
52
+ };
53
+
54
+ interface IWSMessage {
55
+ op: discord_typings.GatewayOpcode;
56
+ d?: any;
57
+ s?: number;
58
+ t?: discord_typings.GatewayEvent;
59
+ }
60
+ interface IGatewayMessage extends IWSMessage {
61
+ shard_id: number;
62
+ }
63
+ interface IClientOptions {
64
+ largeGuildThreshold?: number;
65
+ /**
66
+ * A note on "auto" sharding:
67
+ * "auto" will always start at 0 as there is no way to know the next available shard id.
68
+ * If you have more than one "cluster", you must specify an Array of shard ids. along with totalShards
69
+ */
70
+ shards?: "auto" | Array<number>;
71
+ /**
72
+ * Ignored and overwrote if using "auto" sharding.
73
+ * The total number of shards expected across all clusters.
74
+ */
75
+ totalShards?: number;
76
+ reconnect?: boolean;
77
+ initialPresence?: discord_typings.GatewayPresenceUpdate;
78
+ intents?: IntentResolvable;
79
+ snowtransferInstance?: snowtransfer.SnowTransfer;
80
+ ws?: IClientWSOptions;
81
+ }
82
+ interface IClientWSOptions {
83
+ compress?: boolean;
84
+ encoding?: "etf" | "json";
85
+ }
86
+
87
+ /**
88
+ * RatelimitBucket, used for ratelimiting the execution of functions.
89
+ */
90
+ declare class RatelimitBucket {
91
+ fnQueue: Array<{
92
+ fn: () => unknown;
93
+ callback: () => unknown;
94
+ error: Error;
95
+ }>;
96
+ limit: number;
97
+ remaining: number;
98
+ limitReset: number;
99
+ defaultReset: number | undefined;
100
+ resetTimeout: NodeJS.Timeout | null;
101
+ /**
102
+ * Create a new Bucket.
103
+ * @param limit Number of functions that may be executed during the timeframe set in limitReset.
104
+ * @param limitReset Timeframe in milliseconds until the ratelimit resets.
105
+ * @param defaultReset If the bucket info does not provide default values, but provides remaining, this is the reset to use after the initial reset.
106
+ */
107
+ constructor(limit?: number, limitReset?: number, defaultReset?: number);
108
+ /**
109
+ * Queue a function to be executed.
110
+ * @param fn Function to be executed.
111
+ * @returns Result of the function if any.
112
+ */
113
+ queue<T>(fn: () => T): Promise<T>;
114
+ /**
115
+ * Check if there are any functions in the queue that haven't been executed yet.
116
+ */
117
+ private checkQueue;
118
+ /**
119
+ * Reset the remaining tokens to the base limit.
120
+ */
121
+ private resetRemaining;
122
+ /**
123
+ * Clear the current queue of events to be sent.
124
+ */
125
+ dropQueue(): void;
126
+ }
127
+
128
+ interface BWSEvents {
129
+ ws_open: [];
130
+ ws_close: [number, string];
131
+ ws_message: [IGatewayMessage];
132
+ debug_send: [IWSMessage];
133
+ debug: [string];
134
+ }
135
+ interface BetterWs {
136
+ addListener<E extends keyof BWSEvents>(event: E, listener: (...args: BWSEvents[E]) => any): this;
137
+ emit<E extends keyof BWSEvents>(event: E, ...args: BWSEvents[E]): boolean;
138
+ eventNames(): Array<keyof BWSEvents>;
139
+ listenerCount(event: keyof BWSEvents): number;
140
+ listeners(event: keyof BWSEvents): Array<(...args: Array<any>) => any>;
141
+ off<E extends keyof BWSEvents>(event: E, listener: (...args: BWSEvents[E]) => any): this;
142
+ on<E extends keyof BWSEvents>(event: E, listener: (...args: BWSEvents[E]) => any): this;
143
+ once<E extends keyof BWSEvents>(event: E, listener: (...args: BWSEvents[E]) => any): this;
144
+ prependListener<E extends keyof BWSEvents>(event: E, listener: (...args: BWSEvents[E]) => any): this;
145
+ prependOnceListener<E extends keyof BWSEvents>(event: E, listener: (...args: BWSEvents[E]) => any): this;
146
+ rawListeners(event: keyof BWSEvents): Array<(...args: Array<any>) => any>;
147
+ removeAllListeners(event?: keyof BWSEvents): this;
148
+ removeListener<E extends keyof BWSEvents>(event: E, listener: (...args: BWSEvents[E]) => any): this;
149
+ }
150
+ /**
151
+ * Helper Class for simplifying the websocket connection to Discord.
152
+ */
153
+ declare class BetterWs extends EventEmitter {
154
+ encoding: "etf" | "json";
155
+ compress: boolean;
156
+ address: string;
157
+ options: IClientWSOptions;
158
+ wsBucket: RatelimitBucket;
159
+ presenceBucket: RatelimitBucket;
160
+ private _socket;
161
+ private _internal;
162
+ private _connecting;
163
+ constructor(address: string, options: IClientWSOptions);
164
+ get status(): 1 | 2 | 3 | 4;
165
+ connect(): Promise<void>;
166
+ close(code: number, reason?: string): Promise<void>;
167
+ sendMessage(data: IWSMessage): Promise<void>;
168
+ private _write;
169
+ private _onError;
170
+ private _onClose;
171
+ private _onReadable;
172
+ private _processFrame;
173
+ }
174
+
175
+ interface ConnectorEvents {
176
+ queueIdentify: [number];
177
+ event: [IWSMessage];
178
+ ready: [boolean];
179
+ disconnect: [number, string, boolean];
180
+ stateChange: ["connecting" | "identifying" | "resuming" | "ready" | "disconnected"];
181
+ }
182
+ interface DiscordConnector {
183
+ addListener<E extends keyof ConnectorEvents>(event: E, listener: (...args: ConnectorEvents[E]) => any): this;
184
+ emit<E extends keyof ConnectorEvents>(event: E, ...args: ConnectorEvents[E]): boolean;
185
+ eventNames(): Array<keyof ConnectorEvents>;
186
+ listenerCount(event: keyof ConnectorEvents): number;
187
+ listeners(event: keyof ConnectorEvents): Array<(...args: Array<any>) => any>;
188
+ off<E extends keyof ConnectorEvents>(event: E, listener: (...args: ConnectorEvents[E]) => any): this;
189
+ on<E extends keyof ConnectorEvents>(event: E, listener: (...args: ConnectorEvents[E]) => any): this;
190
+ once<E extends keyof ConnectorEvents>(event: E, listener: (...args: ConnectorEvents[E]) => any): this;
191
+ prependListener<E extends keyof ConnectorEvents>(event: E, listener: (...args: ConnectorEvents[E]) => any): this;
192
+ prependOnceListener<E extends keyof ConnectorEvents>(event: E, listener: (...args: ConnectorEvents[E]) => any): this;
193
+ rawListeners(event: keyof ConnectorEvents): Array<(...args: Array<any>) => any>;
194
+ removeAllListeners(event?: keyof ConnectorEvents): this;
195
+ removeListener<E extends keyof ConnectorEvents>(event: E, listener: (...args: ConnectorEvents[E]) => any): this;
196
+ }
197
+ /**
198
+ * Class used for acting based on received events.
199
+ *
200
+ * This class is automatically instantiated by the library and is documented for reference.
201
+ */
202
+ declare class DiscordConnector extends EventEmitter {
203
+ id: number;
204
+ client: EventEmitter;
205
+ options: Omit<IClientOptions, "snowtransferInstance"> & {
206
+ token: string;
207
+ endpoint?: string;
208
+ };
209
+ reconnect: boolean;
210
+ betterWs: BetterWs;
211
+ heartbeatTimeout: NodeJS.Timeout | null;
212
+ heartbeatInterval: number;
213
+ _trace: string | null;
214
+ seq: number;
215
+ status: "connecting" | "identifying" | "resuming" | "ready" | "disconnected";
216
+ sessionId: string | null;
217
+ lastACKAt: number;
218
+ lastHeartbeatSend: number;
219
+ latency: number;
220
+ private _closing;
221
+ identifyAddress: string;
222
+ resumeAddress: string | null;
223
+ static readonly default: typeof DiscordConnector;
224
+ /**
225
+ * Create a new Discord Connector.
226
+ * @param id id of the shard that created this class.
227
+ * @param client Main client instance.
228
+ */
229
+ constructor(id: number, client: EventEmitter & {
230
+ options: Omit<IClientOptions, "snowtransferInstance"> & {
231
+ token: string;
232
+ endpoint?: string;
233
+ };
234
+ });
235
+ /**
236
+ * Connect to Discord.
237
+ */
238
+ connect(): Promise<void>;
239
+ /**
240
+ * Close the websocket connection and disconnect.
241
+ */
242
+ disconnect(): Promise<void>;
243
+ /**
244
+ * Called with a parsed Websocket message to execute further actions.
245
+ * @param message Message that was received.
246
+ */
247
+ private messageAction;
248
+ /**
249
+ * Reset this connector to be ready to resume or hard reconnect, then connect.
250
+ * @param resume Whether or not the client intends to send an OP 6 RESUME later.
251
+ */
252
+ private _reconnect;
253
+ /**
254
+ * Hard reset this connector.
255
+ */
256
+ private reset;
257
+ /**
258
+ * Clear the heart beat interval, set it to null and set the cached heartbeat_interval as 0.
259
+ */
260
+ private clearHeartBeat;
261
+ /**
262
+ * Send an OP 2 IDENTIFY to the gateway or an OP 6 RESUME if forceful identify is falsy.
263
+ * @param force Whether CloudStorm should send an OP 2 IDENTIFY even if there's a session that could be resumed.
264
+ */
265
+ identify(force?: boolean): Promise<void>;
266
+ /**
267
+ * Send an OP 6 RESUME to the gateway.
268
+ */
269
+ private resume;
270
+ /**
271
+ * Send an OP 1 HEARTBEAT to the gateway.
272
+ */
273
+ private heartbeat;
274
+ /**
275
+ * Handle dispatch events.
276
+ * @param message Message received from the websocket.
277
+ */
278
+ private handleDispatch;
279
+ /**
280
+ * Handle a close from the underlying websocket.
281
+ * @param code Websocket close code.
282
+ * @param reason Close reason if any.
283
+ */
284
+ private handleWsClose;
285
+ /**
286
+ * Send an OP 3 PRESENCE_UPDATE to the gateway.
287
+ * @param data Presence data to send.
288
+ */
289
+ presenceUpdate(data: discord_typings.GatewayPresenceUpdate): Promise<void>;
290
+ /**
291
+ * Send an OP 4 VOICE_STATE_UPDATE to the gateway.
292
+ * @param data Voice state update data to send.
293
+ */
294
+ voiceStateUpdate(data: discord_typings.VoiceStateUpdatePayload & {
295
+ self_deaf?: boolean;
296
+ self_mute?: boolean;
297
+ }): Promise<void>;
298
+ /**
299
+ * Send an OP 8 REQUEST_GUILD_MEMBERS to the gateway.
300
+ * @param data Data to send.
301
+ */
302
+ requestGuildMembers(data: discord_typings.GuildRequestMembersPayload & {
303
+ limit?: number;
304
+ }): Promise<void>;
305
+ /**
306
+ * Checks presence data and fills in missing elements.
307
+ * @param data Data to send.
308
+ * @returns Data after it's fixed/checked.
309
+ */
310
+ private _checkPresenceData;
311
+ /**
312
+ * Checks voice state update data and fills in missing elements.
313
+ * @param data Data to send.
314
+ * @returns Data after it's fixed/checked.
315
+ */
316
+ private _checkVoiceStateUpdateData;
317
+ /**
318
+ * Checks request guild members data and fills in missing elements.
319
+ * @param data Data to send.
320
+ * @returns Data after it's fixed/checked.
321
+ */
322
+ private _checkRequestGuildMembersData;
323
+ }
324
+
325
+ interface ShardEvents {
326
+ disconnect: [number, string, boolean];
327
+ ready: [boolean];
328
+ queueIdentify: [number];
329
+ }
330
+ interface Shard {
331
+ addListener<E extends keyof ShardEvents>(event: E, listener: (...args: ShardEvents[E]) => any): this;
332
+ emit<E extends keyof ShardEvents>(event: E, ...args: ShardEvents[E]): boolean;
333
+ eventNames(): Array<keyof ShardEvents>;
334
+ listenerCount(event: keyof ShardEvents): number;
335
+ listeners(event: keyof ShardEvents): Array<(...args: Array<any>) => any>;
336
+ off<E extends keyof ShardEvents>(event: E, listener: (...args: ShardEvents[E]) => any): this;
337
+ on<E extends keyof ShardEvents>(event: E, listener: (...args: ShardEvents[E]) => any): this;
338
+ once<E extends keyof ShardEvents>(event: E, listener: (...args: ShardEvents[E]) => any): this;
339
+ prependListener<E extends keyof ShardEvents>(event: E, listener: (...args: ShardEvents[E]) => any): this;
340
+ prependOnceListener<E extends keyof ShardEvents>(event: E, listener: (...args: ShardEvents[E]) => any): this;
341
+ rawListeners(event: keyof ShardEvents): Array<(...args: Array<any>) => any>;
342
+ removeAllListeners(event?: keyof ShardEvents): this;
343
+ removeListener<E extends keyof ShardEvents>(event: E, listener: (...args: ShardEvents[E]) => any): this;
344
+ }
345
+ /**
346
+ * Shard class, which provides a wrapper around the DiscordConnector with metadata like the id of the shard.
347
+ *
348
+ * This class is automatically instantiated by the library and is documented for reference.
349
+ */
350
+ declare class Shard extends EventEmitter {
351
+ id: number;
352
+ client: EventEmitter & {
353
+ options: Omit<IClientOptions, "snowtransferInstance"> & {
354
+ token: string;
355
+ endpoint?: string;
356
+ };
357
+ };
358
+ ready: boolean;
359
+ connector: DiscordConnector;
360
+ /**
361
+ * Create a new Shard.
362
+ * @param id id of the shard.
363
+ * @param client Main class used for forwarding events.
364
+ */
365
+ constructor(id: number, client: Shard["client"]);
366
+ /**
367
+ * Time in ms it took for Discord to ackknowledge an OP 1 HEARTBEAT.
368
+ */
369
+ get latency(): number;
370
+ /**
371
+ * Create a new connection to Discord.
372
+ */
373
+ connect(): void;
374
+ /**
375
+ * Close the current connection to Discord.
376
+ */
377
+ disconnect(): Promise<void>;
378
+ /**
379
+ * Send an OP 3 PRESENCE_UPDATE to Discord.
380
+ * @param data Data to send.
381
+ */
382
+ presenceUpdate(data: discord_typings.GatewayPresenceUpdate): Promise<void>;
383
+ /**
384
+ * Send an OP 4 VOICE_STATE_UPDATE to Discord.
385
+ * @param data Data to send
386
+ */
387
+ voiceStateUpdate(data: discord_typings.VoiceStateUpdatePayload & {
388
+ self_deaf?: boolean;
389
+ self_mute?: boolean;
390
+ }): Promise<void>;
391
+ /**
392
+ * Send an OP 8 REQUEST_GUILD_MEMBERS to Discord.
393
+ * @param data Data to send.
394
+ */
395
+ requestGuildMembers(data: discord_typings.GuildRequestMembersPayload & {
396
+ limit?: number;
397
+ }): Promise<void>;
398
+ }
399
+
400
+ /**
401
+ * Class used for managing shards for the user.
402
+ *
403
+ * This class is automatically instantiated by the library and is documented for reference.
404
+ */
405
+ declare class ShardManager {
406
+ client: events.EventEmitter & {
407
+ options: Omit<IClientOptions, "snowtransferInstance"> & {
408
+ token: string;
409
+ endpoint?: string;
410
+ };
411
+ };
412
+ options: ShardManager["client"]["options"];
413
+ shards: {
414
+ [id: number]: Shard;
415
+ };
416
+ identifyBucket: RatelimitBucket;
417
+ concurrencyBucket: RatelimitBucket | null;
418
+ /**
419
+ * Create a new ShardManager.
420
+ */
421
+ constructor(client: ShardManager["client"]);
422
+ /**
423
+ * Create shard instances and add them to the connection queue.
424
+ */
425
+ spawn(): void;
426
+ /**
427
+ * Disconnect all shards facilitated by this manager.
428
+ */
429
+ disconnect(): void;
430
+ /**
431
+ * Add event listeners to a shard to that the manager can act on received events.
432
+ * @param shard Shard to add the event listeners to.
433
+ */
434
+ private _addListener;
435
+ /**
436
+ * Checks if all shards spawned by this manager are ready.
437
+ */
438
+ private _checkReady;
439
+ /**
440
+ * Checks if all shards spawned by this manager are disconnected.
441
+ */
442
+ private _checkDisconnect;
443
+ /**
444
+ * Update the status of all currently connected shards which have been spawned by this manager.
445
+ * @param data Data to send.
446
+ */
447
+ presenceUpdate(data: discord_typings.GatewayPresenceUpdate): Promise<void>;
448
+ /**
449
+ * Update the status of a single connected shard which has been spawned by this manager.
450
+ * @param shardId id of the shard.
451
+ * @param data Data to send.
452
+ */
453
+ shardPresenceUpdate(shardId: number, data: discord_typings.GatewayPresenceUpdate): Promise<void>;
454
+ /**
455
+ * Send an OP 4 VOICE_STATE_UPDATE with a certain shard.
456
+ * @param shardId id of the shard.
457
+ * @param data Data to send.
458
+ */
459
+ voiceStateUpdate(shardId: number, data: discord_typings.VoiceStateUpdatePayload & {
460
+ self_deaf?: boolean;
461
+ self_mute?: boolean;
462
+ }): Promise<void>;
463
+ /**
464
+ * Send an OP 8 REQUEST_GUILD_MEMBERS with a certain shard.
465
+ * @param shardId id of the shard.
466
+ * @param data Data to send.
467
+ */
468
+ requestGuildMembers(shardId: number, data: discord_typings.GuildRequestMembersPayload & {
469
+ limit?: number;
470
+ }): Promise<void>;
471
+ }
472
+
473
+ interface ClientEvents {
474
+ debug: [string];
475
+ rawSend: [IWSMessage];
476
+ rawReceive: [IGatewayMessage];
477
+ event: [IGatewayMessage];
478
+ dispatch: [IGatewayMessage];
479
+ voiceStateUpdate: [IGatewayMessage];
480
+ shardReady: [{
481
+ id: number;
482
+ ready: boolean;
483
+ }];
484
+ error: [string];
485
+ ready: [];
486
+ disconnected: [];
487
+ }
488
+ interface Client {
489
+ addListener<E extends keyof ClientEvents>(event: E, listener: (...args: ClientEvents[E]) => any): this;
490
+ emit<E extends keyof ClientEvents>(event: E, ...args: ClientEvents[E]): boolean;
491
+ eventNames(): Array<keyof ClientEvents>;
492
+ listenerCount(event: keyof ClientEvents): number;
493
+ listeners(event: keyof ClientEvents): Array<(...args: Array<any>) => any>;
494
+ off<E extends keyof ClientEvents>(event: E, listener: (...args: ClientEvents[E]) => any): this;
495
+ on<E extends keyof ClientEvents>(event: E, listener: (...args: ClientEvents[E]) => any): this;
496
+ once<E extends keyof ClientEvents>(event: E, listener: (...args: ClientEvents[E]) => any): this;
497
+ prependListener<E extends keyof ClientEvents>(event: E, listener: (...args: ClientEvents[E]) => any): this;
498
+ prependOnceListener<E extends keyof ClientEvents>(event: E, listener: (...args: ClientEvents[E]) => any): this;
499
+ rawListeners(event: keyof ClientEvents): Array<(...args: Array<any>) => any>;
500
+ removeAllListeners(event?: keyof ClientEvents): this;
501
+ removeListener<E extends keyof ClientEvents>(event: E, listener: (...args: ClientEvents[E]) => any): this;
502
+ }
503
+ /**
504
+ * Main class used for receiving events and interacting with the Discord gateway.
505
+ */
506
+ declare class Client extends EventEmitter {
507
+ token: string;
508
+ options: Omit<IClientOptions, "snowtransferInstance"> & {
509
+ token: string;
510
+ endpoint?: string;
511
+ };
512
+ shardManager: ShardManager;
513
+ version: string;
514
+ private _restClient;
515
+ /**
516
+ * Create a new Client to connect to the Discord gateway.
517
+ * @param token Token received from creating a discord bot user, which will be used to connect to the gateway.
518
+ */
519
+ constructor(token: string, options?: IClientOptions);
520
+ /**
521
+ * Create one or more connections (depending on the selected amount of shards) to the Discord gateway.
522
+ * @returns This function returns a promise which is solely used for awaiting the getGateway() method's return value.
523
+ */
524
+ connect(): Promise<void>;
525
+ /**
526
+ * Method to grab initial connection info from Discord.
527
+ * Should only be called automatically by the lib unless you are a large bot with a max_concurrency not equal to 1.
528
+ * If you are a large bot, you should call this method at a rate of your own discretion to update your max_concurrency cached value to have up to date bucket info.
529
+ * @returns The amount of shards the bot should spawn if set to auto.
530
+ */
531
+ fetchConnectInfo(): Promise<number>;
532
+ /**
533
+ * Get the gateway endpoint to connect to.
534
+ * @returns String url with the Gateway Endpoint to connect to.
535
+ */
536
+ getGateway(): Promise<string>;
537
+ /**
538
+ * Get the GatewayData including recommended amount of shards and other helpful info.
539
+ * @returns Object with url and shards to use to connect to discord.
540
+ */
541
+ getGatewayBot(): Promise<{
542
+ url: string;
543
+ shards: number;
544
+ session_start_limit: discord_typings.SessionStartLimit;
545
+ }>;
546
+ /**
547
+ * Disconnect the bot gracefully,
548
+ * you will receive a 'disconnected' event once the ShardManager successfully closes all shard websocket connections.
549
+ */
550
+ disconnect(): void;
551
+ /**
552
+ * Send an OP 3 PRESENCE_UPDATE to Discord, which updates the status of all shards facilitated by this client's ShardManager.
553
+ * @returns Promise that's resolved once all shards have sent the websocket payload.
554
+ *
555
+ * @example
556
+ * // Connect to Discord and set status to do not disturb and game to "Memes are Dreams".
557
+ * const CloudStorm = require("cloudstorm"); // CloudStorm also supports import statements.
558
+ * const token = "token";
559
+ * const client = new CloudStorm.Client(token);
560
+ * client.connect();
561
+ * client.once("ready", () => {
562
+ * // Client is connected to Discord and is ready, so we can update the status.
563
+ * client.presenceUpdate({ status: "dnd", game: { name: "Memes are Dreams" } });
564
+ * });
565
+ */
566
+ presenceUpdate(data: discord_typings.GatewayPresenceUpdate): Promise<void>;
567
+ /**
568
+ * Send an OP 3 PRESENCE_UPDATE to Discord, which updates the status of a single shard facilitated by this client's ShardManager.
569
+ * @param shardId id of the shard that should update it's status.
570
+ * @param data Presence data to send.
571
+ * @returns Promise that's resolved once the shard has sent the websocket payload.
572
+ *
573
+ * @example
574
+ * // Connect to Discord and set status to do not disturb and game to "Im shard 0".
575
+ * const CloudStorm = require("cloudstorm"); // CloudStorm also supports import statements.
576
+ * const token = "token";
577
+ * const client = new CloudStorm.Client(token);
578
+ * client.connect();
579
+ * client.once("ready", () => {
580
+ * // Client is connected to Discord and is ready, so we can update the status of shard 0.
581
+ * client.shardPresenceUpdate(0, { status: "dnd", game: { name: "Im shard 0" } });
582
+ * });
583
+ */
584
+ shardStatusUpdate(shardId: number, data: discord_typings.GatewayPresenceUpdate): Promise<void>;
585
+ /**
586
+ * Send an OP 4 VOICE_STATE_UPDATE to Discord. this does **not** allow you to send audio with CloudStorm itself,
587
+ * it just provides the necessary data for another application to send audio data to Discord.
588
+ * @param shardId id of the shard that should send the payload.
589
+ * @param data Voice state update data to send.
590
+ * @returns Promise that's resolved once the payload was sent to Discord.
591
+ *
592
+ * @example
593
+ * // Connect to Discord and join a voice channel
594
+ * const CloudStorm = require("cloudstorm"); // CloudStorm also supports import statements.
595
+ * const token = "token";
596
+ * const client = new CloudStorm.Client(token);
597
+ * client.connect();
598
+ * client.once("ready", () => {
599
+ * // Client is connected to Discord and is ready, so we can join a voice channel.
600
+ * // We will use shard 0 as the shard to send the payload.
601
+ * client.voiceStateUpdate(0, { guild_id: "id", channel_id: "id", self_mute: false, self_deaf: false });
602
+ * });
603
+ */
604
+ voiceStateUpdate(shardId: number, data: discord_typings.VoiceStateUpdatePayload & {
605
+ self_deaf?: boolean;
606
+ self_mute?: boolean;
607
+ }): Promise<void>;
608
+ /**
609
+ * Send an OP 8 REQUEST_GUILD_MEMBERS to Discord.
610
+ * @param shardId id of the shard that should send the payload.
611
+ * @param data Request guild members data to send.
612
+ * @returns Promise that's resolved once the payload was send to Discord.
613
+ *
614
+ * @example
615
+ * // Connect to Discord and request guild members.
616
+ * const CloudStorm = require("cloudstorm"); // CloudStorm also supports import statements.
617
+ * const token = "token";
618
+ * const client = new CloudStorm.Client(token);
619
+ * client.connect();
620
+ * client.once("ready", () => {
621
+ * // Client is connected to Discord and is ready, so we can send the request guild members payload.
622
+ * // We will use shard 0 as the shard to send the payload.
623
+ * client.requestGuildMembers(0, { guild_id: "id" });
624
+ * });
625
+ */
626
+ requestGuildMembers(shardId: number, data: discord_typings.GuildRequestMembersPayload & {
627
+ limit?: number;
628
+ }): Promise<void>;
629
+ /**
630
+ * Update the endpoint shard websockets will connect to.
631
+ * @param gatewayUrl Base gateway wss url to update the cached endpoint to.
632
+ */
633
+ private _updateEndpoint;
634
+ }
635
+
636
+ declare const Constants: {
637
+ GATEWAY_OP_CODES: {
638
+ /**
639
+ * Receive.
640
+ */
641
+ DISPATCH: 0;
642
+ /**
643
+ * Send/Receive.
644
+ */
645
+ HEARTBEAT: 1;
646
+ /**
647
+ * Send.
648
+ */
649
+ IDENTIFY: 2;
650
+ /**
651
+ * Send.
652
+ */
653
+ PRESENCE_UPDATE: 3;
654
+ /**
655
+ * Send.
656
+ */
657
+ VOICE_STATE_UPDATE: 4;
658
+ /**
659
+ * Send.
660
+ */
661
+ RESUME: 6;
662
+ /**
663
+ * Receive.
664
+ */
665
+ RECONNECT: 7;
666
+ /**
667
+ * Send.
668
+ */
669
+ REQUEST_GUILD_MEMBERS: 8;
670
+ /**
671
+ * Receive.
672
+ */
673
+ INVALID_SESSION: 9;
674
+ /**
675
+ * Receive.
676
+ */
677
+ HELLO: 10;
678
+ /**
679
+ * Receive.
680
+ */
681
+ HEARTBEAT_ACK: 11;
682
+ };
683
+ GATEWAY_VERSION: 10;
684
+ };
685
+
686
+ export { Client, Constants, IClientOptions, IClientWSOptions, IGatewayMessage, IWSMessage, _default as Intents, Shard, ShardManager };