@discordjs/rest 2.1.0-dev.1699704227-5b0aa92c8 → 2.1.0
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 +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +41 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -18
- package/dist/index.mjs.map +1 -1
- package/dist/strategies/undiciRequest.d.mts +1 -1
- package/dist/strategies/undiciRequest.d.ts +1 -1
- package/dist/{types-65527f29.d.ts → types-0c39b617.d.ts} +12 -1
- package/dist/web.d.mts +1 -1
- package/dist/web.d.ts +1 -1
- package/dist/web.js +41 -18
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +41 -18
- package/dist/web.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ResponseLike, a as RawFile, I as InternalRequest, b as RateLimitData, c as RestEventsMap, H as HashData, d as IHandler, e as RESTOptions, f as RouteLike, g as RequestData } from './types-
|
|
2
|
-
export { A as APIRequest, m as HandlerRequestData, j as InvalidRequestWarningData, i as RateLimitQueueFilter, k as RequestHeaders, l as RequestMethod, h as RestEvents, n as RouteData } from './types-
|
|
1
|
+
import { R as ResponseLike, a as RawFile, I as InternalRequest, b as RateLimitData, c as RestEventsMap, H as HashData, d as IHandler, e as RESTOptions, f as RouteLike, g as RequestData } from './types-0c39b617.js';
|
|
2
|
+
export { A as APIRequest, m as HandlerRequestData, j as InvalidRequestWarningData, i as RateLimitQueueFilter, k as RequestHeaders, l as RequestMethod, h as RestEvents, n as RouteData } from './types-0c39b617.js';
|
|
3
3
|
import * as url from 'url';
|
|
4
4
|
import { Snowflake } from 'discord-api-types/v10';
|
|
5
5
|
import * as undici from 'undici';
|
|
@@ -359,7 +359,9 @@ declare class RateLimitError extends Error implements RateLimitData {
|
|
|
359
359
|
route: string;
|
|
360
360
|
majorParameter: string;
|
|
361
361
|
global: boolean;
|
|
362
|
-
|
|
362
|
+
retryAfter: number;
|
|
363
|
+
sublimitTimeout: number;
|
|
364
|
+
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, }: RateLimitData);
|
|
363
365
|
/**
|
|
364
366
|
* The name of the error
|
|
365
367
|
*/
|
|
@@ -501,7 +503,7 @@ declare class REST extends AsyncEventEmitter<RestEventsMap> {
|
|
|
501
503
|
* @param options - The options to use
|
|
502
504
|
* @returns A populated URLSearchParams instance
|
|
503
505
|
*/
|
|
504
|
-
declare function makeURLSearchParams<
|
|
506
|
+
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
|
505
507
|
/**
|
|
506
508
|
* Converts the response to usable data
|
|
507
509
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ResponseLike, a as RawFile, I as InternalRequest, b as RateLimitData, c as RestEventsMap, H as HashData, d as IHandler, e as RESTOptions, f as RouteLike, g as RequestData } from './types-
|
|
2
|
-
export { A as APIRequest, m as HandlerRequestData, j as InvalidRequestWarningData, i as RateLimitQueueFilter, k as RequestHeaders, l as RequestMethod, h as RestEvents, n as RouteData } from './types-
|
|
1
|
+
import { R as ResponseLike, a as RawFile, I as InternalRequest, b as RateLimitData, c as RestEventsMap, H as HashData, d as IHandler, e as RESTOptions, f as RouteLike, g as RequestData } from './types-0c39b617.js';
|
|
2
|
+
export { A as APIRequest, m as HandlerRequestData, j as InvalidRequestWarningData, i as RateLimitQueueFilter, k as RequestHeaders, l as RequestMethod, h as RestEvents, n as RouteData } from './types-0c39b617.js';
|
|
3
3
|
import * as url from 'url';
|
|
4
4
|
import { Snowflake } from 'discord-api-types/v10';
|
|
5
5
|
import * as undici from 'undici';
|
|
@@ -359,7 +359,9 @@ declare class RateLimitError extends Error implements RateLimitData {
|
|
|
359
359
|
route: string;
|
|
360
360
|
majorParameter: string;
|
|
361
361
|
global: boolean;
|
|
362
|
-
|
|
362
|
+
retryAfter: number;
|
|
363
|
+
sublimitTimeout: number;
|
|
364
|
+
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, }: RateLimitData);
|
|
363
365
|
/**
|
|
364
366
|
* The name of the error
|
|
365
367
|
*/
|
|
@@ -501,7 +503,7 @@ declare class REST extends AsyncEventEmitter<RestEventsMap> {
|
|
|
501
503
|
* @param options - The options to use
|
|
502
504
|
* @returns A populated URLSearchParams instance
|
|
503
505
|
*/
|
|
504
|
-
declare function makeURLSearchParams<
|
|
506
|
+
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
|
505
507
|
/**
|
|
506
508
|
* Converts the response to usable data
|
|
507
509
|
*
|
package/dist/index.js
CHANGED
|
@@ -124,7 +124,7 @@ __name(resolveBody, "resolveBody");
|
|
|
124
124
|
// src/lib/utils/constants.ts
|
|
125
125
|
var import_util = require("@discordjs/util");
|
|
126
126
|
var import_v10 = require("discord-api-types/v10");
|
|
127
|
-
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.1.0
|
|
127
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.1.0)`;
|
|
128
128
|
var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
|
|
129
129
|
var DefaultRestOptions = {
|
|
130
130
|
agent: null,
|
|
@@ -182,7 +182,20 @@ var RateLimitError = class _RateLimitError extends Error {
|
|
|
182
182
|
route;
|
|
183
183
|
majorParameter;
|
|
184
184
|
global;
|
|
185
|
-
|
|
185
|
+
retryAfter;
|
|
186
|
+
sublimitTimeout;
|
|
187
|
+
constructor({
|
|
188
|
+
timeToReset,
|
|
189
|
+
limit,
|
|
190
|
+
method,
|
|
191
|
+
hash,
|
|
192
|
+
url,
|
|
193
|
+
route,
|
|
194
|
+
majorParameter,
|
|
195
|
+
global,
|
|
196
|
+
retryAfter,
|
|
197
|
+
sublimitTimeout
|
|
198
|
+
}) {
|
|
186
199
|
super();
|
|
187
200
|
this.timeToReset = timeToReset;
|
|
188
201
|
this.limit = limit;
|
|
@@ -192,6 +205,8 @@ var RateLimitError = class _RateLimitError extends Error {
|
|
|
192
205
|
this.route = route;
|
|
193
206
|
this.majorParameter = majorParameter;
|
|
194
207
|
this.global = global;
|
|
208
|
+
this.retryAfter = retryAfter;
|
|
209
|
+
this.sublimitTimeout = sublimitTimeout;
|
|
195
210
|
}
|
|
196
211
|
/**
|
|
197
212
|
* The name of the error
|
|
@@ -774,14 +789,16 @@ var BurstHandler = class {
|
|
|
774
789
|
} else if (status === 429) {
|
|
775
790
|
const isGlobal = res.headers.has("X-RateLimit-Global");
|
|
776
791
|
await onRateLimit(this.manager, {
|
|
777
|
-
|
|
778
|
-
limit: Number.POSITIVE_INFINITY,
|
|
792
|
+
global: isGlobal,
|
|
779
793
|
method,
|
|
780
|
-
hash: this.hash,
|
|
781
794
|
url,
|
|
782
795
|
route: routeId.bucketRoute,
|
|
783
796
|
majorParameter: this.majorParameter,
|
|
784
|
-
|
|
797
|
+
hash: this.hash,
|
|
798
|
+
limit: Number.POSITIVE_INFINITY,
|
|
799
|
+
timeToReset: retryAfter,
|
|
800
|
+
retryAfter,
|
|
801
|
+
sublimitTimeout: 0
|
|
785
802
|
});
|
|
786
803
|
this.debug(
|
|
787
804
|
[
|
|
@@ -968,14 +985,16 @@ var SequentialHandler = class {
|
|
|
968
985
|
delay = sleep(timeout);
|
|
969
986
|
}
|
|
970
987
|
const rateLimitData = {
|
|
971
|
-
|
|
972
|
-
limit: limit2,
|
|
988
|
+
global: isGlobal,
|
|
973
989
|
method: options.method ?? "get",
|
|
974
|
-
hash: this.hash,
|
|
975
990
|
url,
|
|
976
991
|
route: routeId.bucketRoute,
|
|
977
992
|
majorParameter: this.majorParameter,
|
|
978
|
-
|
|
993
|
+
hash: this.hash,
|
|
994
|
+
limit: limit2,
|
|
995
|
+
timeToReset: timeout,
|
|
996
|
+
retryAfter: timeout,
|
|
997
|
+
sublimitTimeout: 0
|
|
979
998
|
};
|
|
980
999
|
this.manager.emit("rateLimited" /* RateLimited */, rateLimitData);
|
|
981
1000
|
await onRateLimit(this.manager, rateLimitData);
|
|
@@ -1043,14 +1062,16 @@ var SequentialHandler = class {
|
|
|
1043
1062
|
timeout = this.timeToReset;
|
|
1044
1063
|
}
|
|
1045
1064
|
await onRateLimit(this.manager, {
|
|
1046
|
-
|
|
1047
|
-
limit: limit2,
|
|
1065
|
+
global: isGlobal,
|
|
1048
1066
|
method,
|
|
1049
|
-
hash: this.hash,
|
|
1050
1067
|
url,
|
|
1051
1068
|
route: routeId.bucketRoute,
|
|
1052
1069
|
majorParameter: this.majorParameter,
|
|
1053
|
-
|
|
1070
|
+
hash: this.hash,
|
|
1071
|
+
limit: limit2,
|
|
1072
|
+
timeToReset: timeout,
|
|
1073
|
+
retryAfter,
|
|
1074
|
+
sublimitTimeout: sublimitTimeout ?? 0
|
|
1054
1075
|
});
|
|
1055
1076
|
this.debug(
|
|
1056
1077
|
[
|
|
@@ -1389,9 +1410,11 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1389
1410
|
original: endpoint
|
|
1390
1411
|
};
|
|
1391
1412
|
}
|
|
1392
|
-
const majorIdMatch =
|
|
1393
|
-
|
|
1394
|
-
|
|
1413
|
+
const majorIdMatch = /(?:^\/webhooks\/(\d{17,19}\/[^/?]+))|(?:^\/(?:channels|guilds|webhooks)\/(\d{17,19}))/.exec(
|
|
1414
|
+
endpoint
|
|
1415
|
+
);
|
|
1416
|
+
const majorId = majorIdMatch?.[2] ?? majorIdMatch?.[1] ?? "global";
|
|
1417
|
+
const baseRoute = endpoint.replaceAll(/\d{17,19}/g, ":id").replace(/\/reactions\/(.*)/, "/reactions/:reaction").replace(/\/webhooks\/:id\/[^/?]+/, "/webhooks/:id/:token");
|
|
1395
1418
|
let exceptions = "";
|
|
1396
1419
|
if (method === "DELETE" /* Delete */ && baseRoute === "/channels/:id/messages/:id") {
|
|
1397
1420
|
const id = /\d{17,19}$/.exec(endpoint)[0];
|
|
@@ -1409,7 +1432,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1409
1432
|
};
|
|
1410
1433
|
|
|
1411
1434
|
// src/shared.ts
|
|
1412
|
-
var version = "2.1.0
|
|
1435
|
+
var version = "2.1.0";
|
|
1413
1436
|
|
|
1414
1437
|
// src/index.ts
|
|
1415
1438
|
globalThis.FormData ??= import_undici2.FormData;
|