@discordjs/ws 3.0.0-dev.1753316119-f2fec9177 → 3.0.0-dev.1753613929-c0c1ac287
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.mts +21 -24
- package/dist/index.d.ts +21 -24
- package/dist/index.js +4 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Awaitable } from '@discordjs/util';
|
|
2
|
-
import { GatewayDispatchPayload, GatewayReadyDispatchData, GatewaySendPayload, GatewayOpcodes, GatewayIntentBits, APIGatewayBotInfo,
|
|
2
|
+
import { GatewayDispatchPayload, GatewayReadyDispatchData, GatewaySendPayload, GatewayOpcodes, RESTGetAPIGatewayBotResult, GatewayIntentBits, APIGatewayBotInfo, GatewayIdentifyProperties, GatewayPresenceUpdateData } from 'discord-api-types/v10';
|
|
3
3
|
import { Collection } from '@discordjs/collection';
|
|
4
|
-
import { REST } from '@discordjs/rest';
|
|
5
4
|
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
6
5
|
import { AsyncQueue } from '@sapphire/async-queue';
|
|
7
6
|
|
|
@@ -273,6 +272,22 @@ interface SessionInfo {
|
|
|
273
272
|
* Required options for the WebSocketManager
|
|
274
273
|
*/
|
|
275
274
|
interface RequiredWebSocketManagerOptions {
|
|
275
|
+
/**
|
|
276
|
+
* Function for retrieving the information returned by the `/gateway/bot` endpoint.
|
|
277
|
+
* We recommend using a REST client that respects Discord's rate limits, such as `@discordjs/rest`.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```ts
|
|
281
|
+
* const rest = new REST().setToken(process.env.DISCORD_TOKEN);
|
|
282
|
+
* const manager = new WebSocketManager({
|
|
283
|
+
* token: process.env.DISCORD_TOKEN,
|
|
284
|
+
* fetchGatewayInformation() {
|
|
285
|
+
* return rest.get(Routes.gatewayBot()) as Promise<RESTGetAPIGatewayBotResult>;
|
|
286
|
+
* },
|
|
287
|
+
* });
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
fetchGatewayInformation(): Awaitable<RESTGetAPIGatewayBotResult>;
|
|
276
291
|
/**
|
|
277
292
|
* The intents to request
|
|
278
293
|
*/
|
|
@@ -291,10 +306,13 @@ interface OptionalWebSocketManagerOptions {
|
|
|
291
306
|
*
|
|
292
307
|
* @example
|
|
293
308
|
* ```ts
|
|
309
|
+
* const rest = new REST().setToken(process.env.DISCORD_TOKEN);
|
|
294
310
|
* const manager = new WebSocketManager({
|
|
295
311
|
* token: process.env.DISCORD_TOKEN,
|
|
296
312
|
* intents: 0, // for no intents
|
|
297
|
-
*
|
|
313
|
+
* fetchGatewayInformation() {
|
|
314
|
+
* return rest.get(Routes.gatewayBot()) as Promise<RESTGetAPIGatewayBotResult>;
|
|
315
|
+
* },
|
|
298
316
|
* buildStrategy: (manager) => new WorkerShardingStrategy(manager, { shardsPerWorker: 2 }),
|
|
299
317
|
* });
|
|
300
318
|
* ```
|
|
@@ -312,21 +330,6 @@ interface OptionalWebSocketManagerOptions {
|
|
|
312
330
|
* @defaultValue `'json'`
|
|
313
331
|
*/
|
|
314
332
|
encoding: Encoding;
|
|
315
|
-
/**
|
|
316
|
-
* Fetches the initial gateway URL used to connect to Discord. When missing, this will default to the gateway URL
|
|
317
|
-
* that Discord returns from the `/gateway/bot` route.
|
|
318
|
-
*
|
|
319
|
-
* @example
|
|
320
|
-
* ```ts
|
|
321
|
-
* const manager = new WebSocketManager({
|
|
322
|
-
* token: process.env.DISCORD_TOKEN,
|
|
323
|
-
* fetchGatewayInformation() {
|
|
324
|
-
* return rest.get(Routes.gatewayBot());
|
|
325
|
-
* },
|
|
326
|
-
* })
|
|
327
|
-
* ```
|
|
328
|
-
*/
|
|
329
|
-
fetchGatewayInformation(): Awaitable<RESTGetAPIGatewayBotResult>;
|
|
330
333
|
/**
|
|
331
334
|
* How long to wait for a shard to connect before giving up
|
|
332
335
|
*/
|
|
@@ -351,12 +354,6 @@ interface OptionalWebSocketManagerOptions {
|
|
|
351
354
|
* How long to wait for a shard's READY packet before giving up
|
|
352
355
|
*/
|
|
353
356
|
readyTimeout: number | null;
|
|
354
|
-
/**
|
|
355
|
-
* The REST instance to use for fetching gateway information
|
|
356
|
-
*
|
|
357
|
-
* @deprecated Providing a REST instance is deprecated. Provide the `fetchGatewayInformation` function instead.
|
|
358
|
-
*/
|
|
359
|
-
rest?: REST;
|
|
360
357
|
/**
|
|
361
358
|
* Function used to retrieve session information (and attempt to resume) for a given shard
|
|
362
359
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Awaitable } from '@discordjs/util';
|
|
2
|
-
import { GatewayDispatchPayload, GatewayReadyDispatchData, GatewaySendPayload, GatewayOpcodes, GatewayIntentBits, APIGatewayBotInfo,
|
|
2
|
+
import { GatewayDispatchPayload, GatewayReadyDispatchData, GatewaySendPayload, GatewayOpcodes, RESTGetAPIGatewayBotResult, GatewayIntentBits, APIGatewayBotInfo, GatewayIdentifyProperties, GatewayPresenceUpdateData } from 'discord-api-types/v10';
|
|
3
3
|
import { Collection } from '@discordjs/collection';
|
|
4
|
-
import { REST } from '@discordjs/rest';
|
|
5
4
|
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
6
5
|
import { AsyncQueue } from '@sapphire/async-queue';
|
|
7
6
|
|
|
@@ -273,6 +272,22 @@ interface SessionInfo {
|
|
|
273
272
|
* Required options for the WebSocketManager
|
|
274
273
|
*/
|
|
275
274
|
interface RequiredWebSocketManagerOptions {
|
|
275
|
+
/**
|
|
276
|
+
* Function for retrieving the information returned by the `/gateway/bot` endpoint.
|
|
277
|
+
* We recommend using a REST client that respects Discord's rate limits, such as `@discordjs/rest`.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```ts
|
|
281
|
+
* const rest = new REST().setToken(process.env.DISCORD_TOKEN);
|
|
282
|
+
* const manager = new WebSocketManager({
|
|
283
|
+
* token: process.env.DISCORD_TOKEN,
|
|
284
|
+
* fetchGatewayInformation() {
|
|
285
|
+
* return rest.get(Routes.gatewayBot()) as Promise<RESTGetAPIGatewayBotResult>;
|
|
286
|
+
* },
|
|
287
|
+
* });
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
fetchGatewayInformation(): Awaitable<RESTGetAPIGatewayBotResult>;
|
|
276
291
|
/**
|
|
277
292
|
* The intents to request
|
|
278
293
|
*/
|
|
@@ -291,10 +306,13 @@ interface OptionalWebSocketManagerOptions {
|
|
|
291
306
|
*
|
|
292
307
|
* @example
|
|
293
308
|
* ```ts
|
|
309
|
+
* const rest = new REST().setToken(process.env.DISCORD_TOKEN);
|
|
294
310
|
* const manager = new WebSocketManager({
|
|
295
311
|
* token: process.env.DISCORD_TOKEN,
|
|
296
312
|
* intents: 0, // for no intents
|
|
297
|
-
*
|
|
313
|
+
* fetchGatewayInformation() {
|
|
314
|
+
* return rest.get(Routes.gatewayBot()) as Promise<RESTGetAPIGatewayBotResult>;
|
|
315
|
+
* },
|
|
298
316
|
* buildStrategy: (manager) => new WorkerShardingStrategy(manager, { shardsPerWorker: 2 }),
|
|
299
317
|
* });
|
|
300
318
|
* ```
|
|
@@ -312,21 +330,6 @@ interface OptionalWebSocketManagerOptions {
|
|
|
312
330
|
* @defaultValue `'json'`
|
|
313
331
|
*/
|
|
314
332
|
encoding: Encoding;
|
|
315
|
-
/**
|
|
316
|
-
* Fetches the initial gateway URL used to connect to Discord. When missing, this will default to the gateway URL
|
|
317
|
-
* that Discord returns from the `/gateway/bot` route.
|
|
318
|
-
*
|
|
319
|
-
* @example
|
|
320
|
-
* ```ts
|
|
321
|
-
* const manager = new WebSocketManager({
|
|
322
|
-
* token: process.env.DISCORD_TOKEN,
|
|
323
|
-
* fetchGatewayInformation() {
|
|
324
|
-
* return rest.get(Routes.gatewayBot());
|
|
325
|
-
* },
|
|
326
|
-
* })
|
|
327
|
-
* ```
|
|
328
|
-
*/
|
|
329
|
-
fetchGatewayInformation(): Awaitable<RESTGetAPIGatewayBotResult>;
|
|
330
333
|
/**
|
|
331
334
|
* How long to wait for a shard to connect before giving up
|
|
332
335
|
*/
|
|
@@ -351,12 +354,6 @@ interface OptionalWebSocketManagerOptions {
|
|
|
351
354
|
* How long to wait for a shard's READY packet before giving up
|
|
352
355
|
*/
|
|
353
356
|
readyTimeout: number | null;
|
|
354
|
-
/**
|
|
355
|
-
* The REST instance to use for fetching gateway information
|
|
356
|
-
*
|
|
357
|
-
* @deprecated Providing a REST instance is deprecated. Provide the `fetchGatewayInformation` function instead.
|
|
358
|
-
*/
|
|
359
|
-
rest?: REST;
|
|
360
357
|
/**
|
|
361
358
|
* Function used to retrieve session information (and attempt to resume) for a given shard
|
|
362
359
|
*
|
package/dist/index.js
CHANGED
|
@@ -518,7 +518,7 @@ var CompressionMethod = /* @__PURE__ */ ((CompressionMethod2) => {
|
|
|
518
518
|
CompressionMethod2[CompressionMethod2["ZlibSync"] = 1] = "ZlibSync";
|
|
519
519
|
return CompressionMethod2;
|
|
520
520
|
})(CompressionMethod || {});
|
|
521
|
-
var DefaultDeviceProperty = `@discordjs/ws 3.0.0-dev.
|
|
521
|
+
var DefaultDeviceProperty = `@discordjs/ws 3.0.0-dev.1753613929-c0c1ac287`;
|
|
522
522
|
var getDefaultSessionStore = (0, import_util.lazy)(() => new import_collection4.Collection());
|
|
523
523
|
var CompressionParameterMap = {
|
|
524
524
|
[0 /* ZlibNative */]: "zlib-stream",
|
|
@@ -1449,7 +1449,6 @@ var WorkerBootstrapper = class {
|
|
|
1449
1449
|
// src/ws/WebSocketManager.ts
|
|
1450
1450
|
var import_util3 = require("@discordjs/util");
|
|
1451
1451
|
var import_async_event_emitter2 = require("@vladfrangu/async_event_emitter");
|
|
1452
|
-
var import_v103 = require("discord-api-types/v10");
|
|
1453
1452
|
var WebSocketManager = class extends import_async_event_emitter2.AsyncEventEmitter {
|
|
1454
1453
|
static {
|
|
1455
1454
|
__name(this, "WebSocketManager");
|
|
@@ -1487,18 +1486,12 @@ var WebSocketManager = class extends import_async_event_emitter2.AsyncEventEmitt
|
|
|
1487
1486
|
return this.#token;
|
|
1488
1487
|
}
|
|
1489
1488
|
constructor(options) {
|
|
1490
|
-
if (
|
|
1491
|
-
throw new
|
|
1489
|
+
if (typeof options.fetchGatewayInformation !== "function") {
|
|
1490
|
+
throw new TypeError("fetchGatewayInformation is required");
|
|
1492
1491
|
}
|
|
1493
1492
|
super();
|
|
1494
1493
|
this.options = {
|
|
1495
1494
|
...DefaultWebSocketManagerOptions,
|
|
1496
|
-
fetchGatewayInformation: options.fetchGatewayInformation ?? (async () => {
|
|
1497
|
-
if (!options.rest) {
|
|
1498
|
-
throw new RangeError("A REST instance must be provided if no fetchGatewayInformation function is provided");
|
|
1499
|
-
}
|
|
1500
|
-
return options.rest.get(import_v103.Routes.gatewayBot());
|
|
1501
|
-
}),
|
|
1502
1495
|
...options
|
|
1503
1496
|
};
|
|
1504
1497
|
this.strategy = this.options.buildStrategy(this);
|
|
@@ -1598,7 +1591,7 @@ var WebSocketManager = class extends import_async_event_emitter2.AsyncEventEmitt
|
|
|
1598
1591
|
};
|
|
1599
1592
|
|
|
1600
1593
|
// src/index.ts
|
|
1601
|
-
var version = "3.0.0-dev.
|
|
1594
|
+
var version = "3.0.0-dev.1753613929-c0c1ac287";
|
|
1602
1595
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1603
1596
|
0 && (module.exports = {
|
|
1604
1597
|
CloseCodes,
|