revbot.js 0.1.10 → 0.2.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.mts +9 -7
- package/dist/index.d.ts +9 -7
- package/dist/index.js +56 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -449,9 +449,7 @@ var DEFAULT_CLIENT_OPTIONS = {
|
|
|
449
449
|
reconnect: true
|
|
450
450
|
}
|
|
451
451
|
};
|
|
452
|
-
var
|
|
453
|
-
var apiUrl = "https://api.revolt.chat";
|
|
454
|
-
var cdnUrl = "https://cdn.revoltusercontent.com";
|
|
452
|
+
var apiUrl = "https://api.stoat.chat";
|
|
455
453
|
var SYSTEM_USER_ID = "0".repeat(UUID.TIME_LENGTH + UUID.RANDOM_LENGTH);
|
|
456
454
|
|
|
457
455
|
// src/utils/permissions.ts
|
|
@@ -736,15 +734,15 @@ var User = class extends Base {
|
|
|
736
734
|
});
|
|
737
735
|
}
|
|
738
736
|
avatarURL() {
|
|
739
|
-
var _a, _b, _c
|
|
737
|
+
var _a, _b, _c;
|
|
740
738
|
if (!((_a = this.avatar) == null ? void 0 : _a.id)) return void 0;
|
|
741
|
-
return `${(
|
|
739
|
+
return `${(_b = this.client.options.rest) == null ? void 0 : _b.instanceCDNURL}/avatars/${(_c = this.avatar) == null ? void 0 : _c.id}`;
|
|
742
740
|
}
|
|
743
741
|
displayAvatarURL() {
|
|
744
742
|
return __async(this, null, function* () {
|
|
745
|
-
var _a, _b
|
|
746
|
-
const defaultAvatar = `${(
|
|
747
|
-
return (
|
|
743
|
+
var _a, _b;
|
|
744
|
+
const defaultAvatar = `${(_a = this.client.options.rest) == null ? void 0 : _a.instanceCDNURL}/users/${this.id}/default_avatar`;
|
|
745
|
+
return (_b = this.avatarURL()) != null ? _b : defaultAvatar;
|
|
748
746
|
});
|
|
749
747
|
}
|
|
750
748
|
/**
|
|
@@ -3227,10 +3225,10 @@ var ServerMemberManager = class extends BaseManager {
|
|
|
3227
3225
|
import { EventEmitter } from "node:events";
|
|
3228
3226
|
|
|
3229
3227
|
// src/rest/restClient.ts
|
|
3230
|
-
import { AxiosError } from "axios";
|
|
3228
|
+
import axios4, { AxiosError } from "axios";
|
|
3231
3229
|
|
|
3232
3230
|
// package.json
|
|
3233
|
-
var version = "0.
|
|
3231
|
+
var version = "0.2.0";
|
|
3234
3232
|
|
|
3235
3233
|
// src/rest/restUtils/rateLimitQueue.ts
|
|
3236
3234
|
import axios3 from "axios";
|
|
@@ -3364,6 +3362,26 @@ var RestClient = class {
|
|
|
3364
3362
|
}
|
|
3365
3363
|
});
|
|
3366
3364
|
}
|
|
3365
|
+
getConfig() {
|
|
3366
|
+
return __async(this, null, function* () {
|
|
3367
|
+
var _a, _b;
|
|
3368
|
+
try {
|
|
3369
|
+
const response = yield axios4.get(
|
|
3370
|
+
`${((_a = this.client.options.rest) == null ? void 0 : _a.instanceURL) ? (_b = this.client.options.rest) == null ? void 0 : _b.instanceURL : apiUrl}/`
|
|
3371
|
+
);
|
|
3372
|
+
const config = response.data;
|
|
3373
|
+
this.client.options.rest = __spreadProps(__spreadValues({}, this.client.options.rest), {
|
|
3374
|
+
instanceCDNURL: config.features.autumn.url
|
|
3375
|
+
});
|
|
3376
|
+
this.client.options.ws = __spreadProps(__spreadValues({}, this.client.options.ws), {
|
|
3377
|
+
instanceURL: config.ws
|
|
3378
|
+
});
|
|
3379
|
+
} catch (error) {
|
|
3380
|
+
console.error("Failed to fetch configuration:", error);
|
|
3381
|
+
process.exit(1);
|
|
3382
|
+
}
|
|
3383
|
+
});
|
|
3384
|
+
}
|
|
3367
3385
|
retryRequest(attempt = 0, method, url, body, query) {
|
|
3368
3386
|
return __async(this, null, function* () {
|
|
3369
3387
|
var _a, _b;
|
|
@@ -3464,13 +3482,13 @@ var CDNClient = class {
|
|
|
3464
3482
|
*/
|
|
3465
3483
|
request(method, url, data, query, retry) {
|
|
3466
3484
|
return __async(this, null, function* () {
|
|
3467
|
-
var _a, _b
|
|
3485
|
+
var _a, _b;
|
|
3468
3486
|
try {
|
|
3469
3487
|
if (!this.client.token) throw new Error("Token is required");
|
|
3470
3488
|
const authHeader = this.client.bot ? "X-Bot-Token" : "X-Session-Token";
|
|
3471
3489
|
const config = __spreadProps(__spreadValues({}, {
|
|
3472
3490
|
method,
|
|
3473
|
-
url: `${(
|
|
3491
|
+
url: `${(_a = this.client.options.rest) == null ? void 0 : _a.instanceCDNURL}${url}`,
|
|
3474
3492
|
params: query,
|
|
3475
3493
|
data,
|
|
3476
3494
|
maxBodyLength: Infinity,
|
|
@@ -3480,7 +3498,7 @@ var CDNClient = class {
|
|
|
3480
3498
|
"User-Agent": `RevBot.js/${version}`
|
|
3481
3499
|
}, data.getHeaders())
|
|
3482
3500
|
}), {
|
|
3483
|
-
url: `${(
|
|
3501
|
+
url: `${(_b = this.client.options.rest) == null ? void 0 : _b.instanceCDNURL}${url}`
|
|
3484
3502
|
});
|
|
3485
3503
|
const response = yield this.rateLimitQueue.request(config);
|
|
3486
3504
|
return response.data;
|
|
@@ -3548,11 +3566,11 @@ var BaseClient = class extends EventEmitter {
|
|
|
3548
3566
|
* @param {clientOptions} [options={}] - The options for configuring the client.
|
|
3549
3567
|
*/
|
|
3550
3568
|
constructor(options = {}) {
|
|
3551
|
-
var _a, _b, _c
|
|
3552
|
-
if ((
|
|
3553
|
-
if (!((
|
|
3569
|
+
var _a, _b, _c;
|
|
3570
|
+
if ((_a = options.rest) == null ? void 0 : _a.instanceURL) {
|
|
3571
|
+
if (!((_b = options.rest) == null ? void 0 : _b.instanceURL)) {
|
|
3554
3572
|
console.error(
|
|
3555
|
-
'
|
|
3573
|
+
'instance URLs must be provided (REST) see docs at "https://jade3375.github.io/revbot.js/interfaces/clientOptions.html"'
|
|
3556
3574
|
);
|
|
3557
3575
|
process.exit(0);
|
|
3558
3576
|
} else {
|
|
@@ -3567,7 +3585,7 @@ var BaseClient = class extends EventEmitter {
|
|
|
3567
3585
|
/** Whether the client is a bot. */
|
|
3568
3586
|
this.bot = true;
|
|
3569
3587
|
this.options = __spreadValues(__spreadValues({}, DEFAULT_CLIENT_OPTIONS), options);
|
|
3570
|
-
this.bot = (
|
|
3588
|
+
this.bot = (_c = this.options.isBot) != null ? _c : true;
|
|
3571
3589
|
this.api = new RestClient(this);
|
|
3572
3590
|
this.cdn = new CDNClient(this);
|
|
3573
3591
|
}
|
|
@@ -3775,6 +3793,9 @@ var Message = class extends Event {
|
|
|
3775
3793
|
handle(data) {
|
|
3776
3794
|
return __async(this, null, function* () {
|
|
3777
3795
|
var _a;
|
|
3796
|
+
if (data.system) {
|
|
3797
|
+
return {};
|
|
3798
|
+
}
|
|
3778
3799
|
const channel = this.client.channels.cache.get(data.channel);
|
|
3779
3800
|
if (channel == null ? void 0 : channel.isText()) {
|
|
3780
3801
|
if (((_a = data.user) == null ? void 0 : _a.bot) && this.client.options.ignoreBots) {
|
|
@@ -4407,7 +4428,7 @@ var WebSocketClient = class {
|
|
|
4407
4428
|
* @returns {Promise<this>} A promise that resolves when the connection is established.
|
|
4408
4429
|
*/
|
|
4409
4430
|
connect() {
|
|
4410
|
-
return new Promise((resolve) => {
|
|
4431
|
+
return new Promise((resolve) => __async(this, null, function* () {
|
|
4411
4432
|
var _a, _b, _c, _d;
|
|
4412
4433
|
if (((_a = this.socket) == null ? void 0 : _a.readyState) === WebSocket.OPEN && this.ready) {
|
|
4413
4434
|
return resolve(this);
|
|
@@ -4418,15 +4439,16 @@ var WebSocketClient = class {
|
|
|
4418
4439
|
if (typeof this.client.token !== "string") {
|
|
4419
4440
|
throw new Error("INVALID_TOKEN");
|
|
4420
4441
|
}
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4442
|
+
yield this.client.init();
|
|
4443
|
+
if (!((_b = this.client.options.ws) == null ? void 0 : _b.instanceURL))
|
|
4444
|
+
return Promise.reject(new Error("WebSocket instance URL not set."));
|
|
4445
|
+
const ws = this.socket = (_d = this.socket) != null ? _d : new WebSocket((_c = this.client.options.ws) == null ? void 0 : _c.instanceURL);
|
|
4424
4446
|
ws.onopen = this.onOpen.bind(this);
|
|
4425
4447
|
ws.onmessage = this.onMessage.bind(this);
|
|
4426
4448
|
ws.onerror = this.onError.bind(this);
|
|
4427
4449
|
ws.onclose = this.onClose.bind(this);
|
|
4428
4450
|
ws.addEventListener("open", () => resolve(this));
|
|
4429
|
-
});
|
|
4451
|
+
}));
|
|
4430
4452
|
}
|
|
4431
4453
|
/**
|
|
4432
4454
|
* Destroys the WebSocket connection and clears its state.
|
|
@@ -4472,6 +4494,15 @@ var client2 = class extends BaseClient {
|
|
|
4472
4494
|
/** The timestamp when the client became ready, or `null` if not ready. */
|
|
4473
4495
|
this.readyAt = null;
|
|
4474
4496
|
}
|
|
4497
|
+
/**
|
|
4498
|
+
* Initializes the client.
|
|
4499
|
+
* @private
|
|
4500
|
+
*/
|
|
4501
|
+
init() {
|
|
4502
|
+
return __async(this, null, function* () {
|
|
4503
|
+
yield this.api.getConfig();
|
|
4504
|
+
});
|
|
4505
|
+
}
|
|
4475
4506
|
/**
|
|
4476
4507
|
* Gets the timestamp when the client became ready.
|
|
4477
4508
|
*
|
|
@@ -4592,8 +4623,6 @@ export {
|
|
|
4592
4623
|
VoiceChannel,
|
|
4593
4624
|
WSEvents,
|
|
4594
4625
|
apiUrl,
|
|
4595
|
-
|
|
4596
|
-
client2 as client,
|
|
4597
|
-
wsUrl
|
|
4626
|
+
client2 as client
|
|
4598
4627
|
};
|
|
4599
4628
|
//# sourceMappingURL=index.mjs.map
|