revbot.js 0.1.8 → 0.1.9
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 +33 -17
- package/dist/index.d.ts +33 -17
- package/dist/index.js +27 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -90,6 +90,7 @@ var _BaseManager = class _BaseManager {
|
|
|
90
90
|
/**
|
|
91
91
|
* Adds a raw object to the cache, constructing the holdable class.
|
|
92
92
|
* Automatically evicts oldest entries if the max size is exceeded.
|
|
93
|
+
* @private
|
|
93
94
|
*/
|
|
94
95
|
_add(raw) {
|
|
95
96
|
if (!this.holds) throw new Error("Holds is not defined");
|
|
@@ -98,7 +99,9 @@ var _BaseManager = class _BaseManager {
|
|
|
98
99
|
this.enforceMaxSize();
|
|
99
100
|
return obj;
|
|
100
101
|
}
|
|
101
|
-
/** Remove an entry by id.
|
|
102
|
+
/** Remove an entry by id.
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
102
105
|
_remove(id) {
|
|
103
106
|
this.cache.delete(id);
|
|
104
107
|
}
|
|
@@ -2500,8 +2503,10 @@ var Emoji2 = class extends Base {
|
|
|
2500
2503
|
var ChannelManager = class extends BaseManager {
|
|
2501
2504
|
constructor() {
|
|
2502
2505
|
super(...arguments);
|
|
2506
|
+
/** @private */
|
|
2503
2507
|
this.holds = null;
|
|
2504
2508
|
}
|
|
2509
|
+
/** @private */
|
|
2505
2510
|
_add(data) {
|
|
2506
2511
|
let channel;
|
|
2507
2512
|
switch (data.channel_type) {
|
|
@@ -2595,8 +2600,10 @@ var ChannelManager = class extends BaseManager {
|
|
|
2595
2600
|
var ServerManager = class extends BaseManager {
|
|
2596
2601
|
constructor() {
|
|
2597
2602
|
super(...arguments);
|
|
2603
|
+
/** @private */
|
|
2598
2604
|
this.holds = Server2;
|
|
2599
2605
|
}
|
|
2606
|
+
/** @private */
|
|
2600
2607
|
_remove(id) {
|
|
2601
2608
|
var _a;
|
|
2602
2609
|
const server = this.cache.get(id);
|
|
@@ -2649,6 +2656,7 @@ var ServerManager = class extends BaseManager {
|
|
|
2649
2656
|
var UserManager = class extends BaseManager {
|
|
2650
2657
|
constructor() {
|
|
2651
2658
|
super(...arguments);
|
|
2659
|
+
/** @private */
|
|
2652
2660
|
this.holds = User;
|
|
2653
2661
|
}
|
|
2654
2662
|
/**
|
|
@@ -2692,6 +2700,7 @@ var MessageManager = class extends BaseManager {
|
|
|
2692
2700
|
constructor(channel, maxSize = 1e3) {
|
|
2693
2701
|
super(channel.client, maxSize);
|
|
2694
2702
|
this.channel = channel;
|
|
2703
|
+
/** @private */
|
|
2695
2704
|
this.holds = MessageStruct;
|
|
2696
2705
|
}
|
|
2697
2706
|
/**
|
|
@@ -2935,8 +2944,10 @@ var RoleManager = class extends BaseManager {
|
|
|
2935
2944
|
constructor(server) {
|
|
2936
2945
|
super(server.client);
|
|
2937
2946
|
this.server = server;
|
|
2947
|
+
/** @private */
|
|
2938
2948
|
this.holds = Role;
|
|
2939
2949
|
}
|
|
2950
|
+
/** @private */
|
|
2940
2951
|
_add(data) {
|
|
2941
2952
|
const role = new Role(this.server, data);
|
|
2942
2953
|
this.cache.set(role.id, role);
|
|
@@ -3008,8 +3019,10 @@ var ServerChannelManager = class extends BaseManager {
|
|
|
3008
3019
|
constructor(server) {
|
|
3009
3020
|
super(server.client);
|
|
3010
3021
|
this.server = server;
|
|
3022
|
+
/** @private */
|
|
3011
3023
|
this.holds = ServerChannel;
|
|
3012
3024
|
}
|
|
3025
|
+
/** @private */
|
|
3013
3026
|
_add(data) {
|
|
3014
3027
|
let channel;
|
|
3015
3028
|
switch (data.channel_type) {
|
|
@@ -3028,11 +3041,12 @@ var ServerChannelManager = class extends BaseManager {
|
|
|
3028
3041
|
return channel;
|
|
3029
3042
|
}
|
|
3030
3043
|
/**
|
|
3031
|
-
*
|
|
3032
|
-
* @param
|
|
3033
|
-
* @param
|
|
3034
|
-
* @param
|
|
3035
|
-
* @
|
|
3044
|
+
* Creates a new channel in the server.
|
|
3045
|
+
* @param options - Options for creating the channel.
|
|
3046
|
+
* @param options.name - The name of the channel to create.
|
|
3047
|
+
* @param [options.type="Text"] - The type of the channel to create. Can be "Text" or "Voice". Defaults to "Text".
|
|
3048
|
+
* @param [options.description] - The description of the channel to create. Only used for voice channels.
|
|
3049
|
+
* @returns A promise that resolves to the created channel.
|
|
3036
3050
|
*/
|
|
3037
3051
|
create(_0) {
|
|
3038
3052
|
return __async(this, arguments, function* ({
|
|
@@ -3084,6 +3098,7 @@ var ServerMemberManager = class extends BaseManager {
|
|
|
3084
3098
|
constructor(server) {
|
|
3085
3099
|
super(server.client);
|
|
3086
3100
|
this.server = server;
|
|
3101
|
+
/** @private */
|
|
3087
3102
|
this.holds = ServerMember3;
|
|
3088
3103
|
}
|
|
3089
3104
|
/**
|
|
@@ -3297,7 +3312,7 @@ var RestClient = class {
|
|
|
3297
3312
|
*/
|
|
3298
3313
|
request(method, url, body, query, retry) {
|
|
3299
3314
|
return __async(this, null, function* () {
|
|
3300
|
-
var _a, _b, _c;
|
|
3315
|
+
var _a, _b, _c, _d, _e;
|
|
3301
3316
|
try {
|
|
3302
3317
|
if (!this.client.token) throw new Error("Token is required");
|
|
3303
3318
|
const authHeader = this.client.bot ? "X-Bot-Token" : "X-Session-Token";
|
|
@@ -3311,7 +3326,7 @@ var RestClient = class {
|
|
|
3311
3326
|
"User-Agent": `RevBot.js/${version}`
|
|
3312
3327
|
}
|
|
3313
3328
|
}), {
|
|
3314
|
-
url: `${apiUrl}${url}`
|
|
3329
|
+
url: `${((_c = this.client.options.rest) == null ? void 0 : _c.instanceURL) ? (_d = this.client.options.rest) == null ? void 0 : _d.instanceURL : apiUrl}${url}`
|
|
3315
3330
|
});
|
|
3316
3331
|
const response = yield this.rateLimitQueue.request(config);
|
|
3317
3332
|
return response.data;
|
|
@@ -3323,7 +3338,7 @@ var RestClient = class {
|
|
|
3323
3338
|
}
|
|
3324
3339
|
if (error.status) {
|
|
3325
3340
|
throw new Error(
|
|
3326
|
-
`API call failed with status ${error.status}: ${(
|
|
3341
|
+
`API call failed with status ${error.status}: ${(_e = error.response) == null ? void 0 : _e.statusText}`
|
|
3327
3342
|
);
|
|
3328
3343
|
}
|
|
3329
3344
|
}
|
|
@@ -3499,7 +3514,6 @@ var CDNClient = class {
|
|
|
3499
3514
|
* POST request.
|
|
3500
3515
|
* @param url The URL for the request.
|
|
3501
3516
|
* @param data The request body.
|
|
3502
|
-
* @param query Query parameters (if applicable).
|
|
3503
3517
|
* @returns The API response.
|
|
3504
3518
|
*/
|
|
3505
3519
|
post(url, data) {
|
|
@@ -3599,6 +3613,7 @@ var ChannelCreate = class extends Event {
|
|
|
3599
3613
|
*
|
|
3600
3614
|
* @param {API.Channel} data - The raw data for the created channel from the API.
|
|
3601
3615
|
* @returns {Promise<{ channel: unknown }>} A promise that resolves with the created channel.
|
|
3616
|
+
* @private
|
|
3602
3617
|
*/
|
|
3603
3618
|
handle(data) {
|
|
3604
3619
|
return __async(this, null, function* () {
|
|
@@ -3739,6 +3754,7 @@ var Message = class extends Event {
|
|
|
3739
3754
|
*
|
|
3740
3755
|
* @param {API.Message} data - The raw data for the message from the API.
|
|
3741
3756
|
* @returns {Promise<{ message: unknown }>} A promise that resolves with the created message, or an empty object if the channel is not text-based.
|
|
3757
|
+
* @private
|
|
3742
3758
|
*/
|
|
3743
3759
|
handle(data) {
|
|
3744
3760
|
return __async(this, null, function* () {
|
|
@@ -3808,6 +3824,7 @@ var ServerCreate = class extends Event {
|
|
|
3808
3824
|
*
|
|
3809
3825
|
* @param {API.Server} data - The raw data for the created server from the API.
|
|
3810
3826
|
* @returns {Promise<void>} A promise that resolves when the server is added and members are optionally fetched.
|
|
3827
|
+
* @private
|
|
3811
3828
|
*/
|
|
3812
3829
|
handle(data) {
|
|
3813
3830
|
return __async(this, null, function* () {
|