cloudstorm 0.9.5 → 0.10.1
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 +17 -54
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as discord_api_types_v10 from 'discord-api-types/v10';
|
|
2
2
|
import { GatewayReceivePayload, GatewayDispatchPayload, GatewayPresenceUpdateData, GatewaySendPayload, GatewayVoiceStateUpdateData, GatewayRequestGuildMembersData } from 'discord-api-types/v10';
|
|
3
3
|
import * as snowtransfer from 'snowtransfer';
|
|
4
|
+
import { LocalBucket } from 'snowtransfer';
|
|
4
5
|
import * as events from 'events';
|
|
5
6
|
import { EventEmitter } from 'events';
|
|
7
|
+
import * as zlib from 'zlib';
|
|
6
8
|
|
|
7
9
|
type IntentFlags = typeof flags;
|
|
8
10
|
type IntentResolvable = number | Array<number> | keyof IntentFlags | Array<keyof IntentFlags>;
|
|
@@ -94,50 +96,6 @@ interface IClientWSOptions {
|
|
|
94
96
|
encoding?: "etf" | "json";
|
|
95
97
|
}
|
|
96
98
|
|
|
97
|
-
/**
|
|
98
|
-
* RatelimitBucket, used for ratelimiting the execution of functions.
|
|
99
|
-
*/
|
|
100
|
-
declare class RatelimitBucket {
|
|
101
|
-
limit: number;
|
|
102
|
-
limitReset: number;
|
|
103
|
-
defaultReset?: number | undefined;
|
|
104
|
-
/** Functions waiting to be executed. */
|
|
105
|
-
fnQueue: Array<{
|
|
106
|
-
fn: () => unknown;
|
|
107
|
-
callback: () => unknown;
|
|
108
|
-
error: Error;
|
|
109
|
-
}>;
|
|
110
|
-
/** How many more functions can be executed before this bucket needs to wait to reset. */
|
|
111
|
-
remaining: number;
|
|
112
|
-
/** The Timeout that when executed, will reset this bucket's remaining to the limit. Null if remaining is the limit. */
|
|
113
|
-
resetTimeout: NodeJS.Timeout | null;
|
|
114
|
-
/**
|
|
115
|
-
* Create a new Bucket.
|
|
116
|
-
* @param limit Number of functions that may be executed during the timeframe set in limitReset.
|
|
117
|
-
* @param limitReset Timeframe in milliseconds until the ratelimit resets.
|
|
118
|
-
* @param defaultReset If the bucket info does not provide default values, but provides remaining, this is the reset to use after the initial reset.
|
|
119
|
-
*/
|
|
120
|
-
constructor(limit?: number, limitReset?: number, defaultReset?: number | undefined);
|
|
121
|
-
/**
|
|
122
|
-
* Queue a function to be executed.
|
|
123
|
-
* @param fn Function to be executed.
|
|
124
|
-
* @returns Result of the function if any.
|
|
125
|
-
*/
|
|
126
|
-
queue<T>(fn: () => T): Promise<T>;
|
|
127
|
-
/**
|
|
128
|
-
* Check if there are any functions in the queue that haven't been executed yet.
|
|
129
|
-
*/
|
|
130
|
-
private checkQueue;
|
|
131
|
-
/**
|
|
132
|
-
* Reset the remaining tokens to the base limit.
|
|
133
|
-
*/
|
|
134
|
-
private resetRemaining;
|
|
135
|
-
/**
|
|
136
|
-
* Clear the current queue of events to be sent.
|
|
137
|
-
*/
|
|
138
|
-
dropQueue(): void;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
99
|
interface BWSEvents {
|
|
142
100
|
ws_open: [];
|
|
143
101
|
ws_close: [number, string];
|
|
@@ -171,13 +129,19 @@ declare class BetterWs extends EventEmitter {
|
|
|
171
129
|
/** If the messages sent/received are compressed with zlib. */
|
|
172
130
|
compress: boolean;
|
|
173
131
|
/** The ratelimit bucket for how many packets this ws can send within a time frame. */
|
|
174
|
-
wsBucket:
|
|
132
|
+
wsBucket: LocalBucket;
|
|
175
133
|
/** The ratelimit bucket for how many presence update specific packets this ws can send within a time frame. Is still affected by the overall packet send bucket. */
|
|
176
|
-
presenceBucket:
|
|
134
|
+
presenceBucket: LocalBucket;
|
|
177
135
|
/** The raw net.Socket retreived from upgrading the connection or null if not upgraded/closed. */
|
|
178
136
|
private _socket;
|
|
179
137
|
/** Internal properties that need a funny way to be referenced. */
|
|
180
|
-
|
|
138
|
+
_internal: {
|
|
139
|
+
openRejector: ((reason?: any) => void) | null;
|
|
140
|
+
/** A promise that resolves when the connection is fully closed or null if not closing the connection if any. */
|
|
141
|
+
closePromise: Promise<void> | null;
|
|
142
|
+
/** A zlib Inflate instance if messages sent/received are going to be compressed. Auto created on connect. */
|
|
143
|
+
zlib: zlib.Inflate | null;
|
|
144
|
+
};
|
|
181
145
|
/** If a request is going through to initiate a WebSocket connection and hasn't been upgraded by the server yet. */
|
|
182
146
|
private _connecting;
|
|
183
147
|
/** Code received from frame op 8 */
|
|
@@ -320,7 +284,6 @@ declare class DiscordConnector extends EventEmitter {
|
|
|
320
284
|
private _openToHeartbeatTimeout;
|
|
321
285
|
/** A Timeout that, when triggered, sends the first heartbeat */
|
|
322
286
|
private _initialHeartbeatTimeout;
|
|
323
|
-
static readonly default: typeof DiscordConnector;
|
|
324
287
|
/**
|
|
325
288
|
* Creates a new Discord Connector.
|
|
326
289
|
* @param id id of the shard that created this class.
|
|
@@ -362,11 +325,11 @@ declare class DiscordConnector extends EventEmitter {
|
|
|
362
325
|
* Clear the heart beat interval, set it to null and set the cached heartbeat_interval as 0.
|
|
363
326
|
*/
|
|
364
327
|
private clearHeartBeat;
|
|
328
|
+
private _onHello;
|
|
365
329
|
/**
|
|
366
|
-
* Send an OP 2 IDENTIFY to the gateway
|
|
367
|
-
* @param force Whether CloudStorm should send an OP 2 IDENTIFY even if there's a session that could be resumed.
|
|
330
|
+
* Send an OP 2 IDENTIFY to the gateway.
|
|
368
331
|
*/
|
|
369
|
-
identify(
|
|
332
|
+
identify(): Promise<void>;
|
|
370
333
|
/**
|
|
371
334
|
* Send an OP 6 RESUME to the gateway.
|
|
372
335
|
*/
|
|
@@ -522,9 +485,9 @@ declare class ShardManager {
|
|
|
522
485
|
[id: number]: Shard;
|
|
523
486
|
};
|
|
524
487
|
/** The bucket used to identify a certain number of shards within a day. */
|
|
525
|
-
identifyBucket:
|
|
488
|
+
identifyBucket: LocalBucket;
|
|
526
489
|
/** The bucket used to identify x number of shards within 5 second intervals. Larger bots benefit from this, but doesn't change how many times per day any shards can identify. */
|
|
527
|
-
concurrencyBucket:
|
|
490
|
+
concurrencyBucket: LocalBucket | null;
|
|
528
491
|
/**
|
|
529
492
|
* Create a new ShardManager.
|
|
530
493
|
*/
|
|
@@ -789,4 +752,4 @@ declare const Constants: {
|
|
|
789
752
|
GATEWAY_VERSION: 10;
|
|
790
753
|
};
|
|
791
754
|
|
|
792
|
-
export { BetterWs, Client, Constants, IClientOptions, IClientWSOptions, IGatewayDispatch, IGatewayMessage, _default as Intents, Shard, ShardManager };
|
|
755
|
+
export { BetterWs, Client, Constants, type IClientOptions, type IClientWSOptions, type IGatewayDispatch, type IGatewayMessage, _default as Intents, Shard, ShardManager };
|