revbot.js 0.2.0 → 0.2.2
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/README.md +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +28 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Note: this package is currently in the early stages of development and testing
|
|
4
4
|
|
|
5
5
|
`revbot.js` is a Node.js library for building bots on the Revolt platform. It provides an easy-to-use interface for interacting with Revolt's API, managing events, and handling various bot functionalities. NOTE: node 21 is required to run this
|
|
6
|
-
[revolt server](https://
|
|
6
|
+
[revolt server](https://stt.gg/cFSwBt4R) [docs](https://jade3375.github.io/revbot.js/)
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2190,6 +2190,8 @@ declare class WebSocketClient {
|
|
|
2190
2190
|
reconnecting: Promise<unknown> | null;
|
|
2191
2191
|
/** Whether the WebSocket client is ready. */
|
|
2192
2192
|
ready: boolean;
|
|
2193
|
+
/** The number of reconnection attempts made. */
|
|
2194
|
+
retryCount: number;
|
|
2193
2195
|
/**
|
|
2194
2196
|
* Creates a new WebSocketClient instance.
|
|
2195
2197
|
*
|
|
@@ -2272,7 +2274,7 @@ declare class WebSocketClient {
|
|
|
2272
2274
|
*
|
|
2273
2275
|
* @returns {Promise<void>} A promise that resolves when the connection is destroyed.
|
|
2274
2276
|
*/
|
|
2275
|
-
destroy(): Promise<void>;
|
|
2277
|
+
destroy(isUserInitiated?: boolean): Promise<void>;
|
|
2276
2278
|
}
|
|
2277
2279
|
|
|
2278
2280
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2190,6 +2190,8 @@ declare class WebSocketClient {
|
|
|
2190
2190
|
reconnecting: Promise<unknown> | null;
|
|
2191
2191
|
/** Whether the WebSocket client is ready. */
|
|
2192
2192
|
ready: boolean;
|
|
2193
|
+
/** The number of reconnection attempts made. */
|
|
2194
|
+
retryCount: number;
|
|
2193
2195
|
/**
|
|
2194
2196
|
* Creates a new WebSocketClient instance.
|
|
2195
2197
|
*
|
|
@@ -2272,7 +2274,7 @@ declare class WebSocketClient {
|
|
|
2272
2274
|
*
|
|
2273
2275
|
* @returns {Promise<void>} A promise that resolves when the connection is destroyed.
|
|
2274
2276
|
*/
|
|
2275
|
-
destroy(): Promise<void>;
|
|
2277
|
+
destroy(isUserInitiated?: boolean): Promise<void>;
|
|
2276
2278
|
}
|
|
2277
2279
|
|
|
2278
2280
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3304,7 +3304,7 @@ var import_node_events = require("events");
|
|
|
3304
3304
|
var import_axios4 = __toESM(require("axios"));
|
|
3305
3305
|
|
|
3306
3306
|
// package.json
|
|
3307
|
-
var version = "0.2.
|
|
3307
|
+
var version = "0.2.1";
|
|
3308
3308
|
|
|
3309
3309
|
// src/rest/restUtils/rateLimitQueue.ts
|
|
3310
3310
|
var import_axios3 = __toESM(require("axios"));
|
|
@@ -3869,6 +3869,9 @@ var Message = class extends Event {
|
|
|
3869
3869
|
handle(data) {
|
|
3870
3870
|
return __async(this, null, function* () {
|
|
3871
3871
|
var _a;
|
|
3872
|
+
if (data.system) {
|
|
3873
|
+
return {};
|
|
3874
|
+
}
|
|
3872
3875
|
const channel = this.client.channels.cache.get(data.channel);
|
|
3873
3876
|
if (channel == null ? void 0 : channel.isText()) {
|
|
3874
3877
|
if (((_a = data.user) == null ? void 0 : _a.bot) && this.client.options.ignoreBots) {
|
|
@@ -4303,6 +4306,8 @@ var WebSocketClient = class {
|
|
|
4303
4306
|
this.reconnecting = null;
|
|
4304
4307
|
/** Whether the WebSocket client is ready. */
|
|
4305
4308
|
this.ready = false;
|
|
4309
|
+
/** The number of reconnection attempts made. */
|
|
4310
|
+
this.retryCount = 0;
|
|
4306
4311
|
}
|
|
4307
4312
|
/**
|
|
4308
4313
|
* Logs a debug message.
|
|
@@ -4442,6 +4447,8 @@ var WebSocketClient = class {
|
|
|
4442
4447
|
break;
|
|
4443
4448
|
case "Authenticated" /* AUTHENTICATED */:
|
|
4444
4449
|
this.connected = true;
|
|
4450
|
+
this.retryCount = 0;
|
|
4451
|
+
this.debug(`Successfully authenticated.`);
|
|
4445
4452
|
break;
|
|
4446
4453
|
case "Pong" /* PONG */:
|
|
4447
4454
|
this.debug(`Received a heartbeat.`);
|
|
@@ -4501,6 +4508,15 @@ var WebSocketClient = class {
|
|
|
4501
4508
|
* @returns {Promise<this>} A promise that resolves when the connection is established.
|
|
4502
4509
|
*/
|
|
4503
4510
|
connect() {
|
|
4511
|
+
this.retryCount = this.retryCount + 1;
|
|
4512
|
+
if (this.retryCount > 10) {
|
|
4513
|
+
this.debug("Max retry attempts reached");
|
|
4514
|
+
return Promise.reject(
|
|
4515
|
+
new Error(
|
|
4516
|
+
"Max retry attempts reached on WS connection, try again later."
|
|
4517
|
+
)
|
|
4518
|
+
);
|
|
4519
|
+
}
|
|
4504
4520
|
return new Promise((resolve) => __async(this, null, function* () {
|
|
4505
4521
|
var _a, _b, _c, _d;
|
|
4506
4522
|
if (((_a = this.socket) == null ? void 0 : _a.readyState) === WebSocket.OPEN && this.ready) {
|
|
@@ -4528,7 +4544,7 @@ var WebSocketClient = class {
|
|
|
4528
4544
|
*
|
|
4529
4545
|
* @returns {Promise<void>} A promise that resolves when the connection is destroyed.
|
|
4530
4546
|
*/
|
|
4531
|
-
destroy() {
|
|
4547
|
+
destroy(isUserInitiated) {
|
|
4532
4548
|
return new Promise((resolve) => {
|
|
4533
4549
|
var _a;
|
|
4534
4550
|
this.setHeartbeatTimer(-1);
|
|
@@ -4537,11 +4553,20 @@ var WebSocketClient = class {
|
|
|
4537
4553
|
if (((_a = this.socket) == null ? void 0 : _a.readyState) === WebSocket.OPEN) {
|
|
4538
4554
|
this.socket.addEventListener("close", () => {
|
|
4539
4555
|
this.socket = null;
|
|
4556
|
+
if (!isUserInitiated) {
|
|
4557
|
+
setTimeout(() => this.connect(), 1e3);
|
|
4558
|
+
}
|
|
4540
4559
|
resolve();
|
|
4541
4560
|
});
|
|
4542
4561
|
this.socket.close();
|
|
4562
|
+
if (!isUserInitiated) {
|
|
4563
|
+
setTimeout(() => this.connect(), 1e3);
|
|
4564
|
+
}
|
|
4543
4565
|
} else {
|
|
4544
4566
|
this.socket = null;
|
|
4567
|
+
if (!isUserInitiated) {
|
|
4568
|
+
setTimeout(() => this.connect(), 1e3);
|
|
4569
|
+
}
|
|
4545
4570
|
resolve();
|
|
4546
4571
|
}
|
|
4547
4572
|
});
|
|
@@ -4633,7 +4658,7 @@ var client2 = class extends BaseClient {
|
|
|
4633
4658
|
this.token = null;
|
|
4634
4659
|
this.user = null;
|
|
4635
4660
|
this.readyAt = null;
|
|
4636
|
-
yield this.ws.destroy();
|
|
4661
|
+
yield this.ws.destroy(true);
|
|
4637
4662
|
});
|
|
4638
4663
|
}
|
|
4639
4664
|
/**
|