@discordjs/rest 2.1.1-dev.1700006959-cab60142f → 2.2.0-dev.1700136223-6df233de1
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 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -8
- package/dist/index.mjs.map +1 -1
- package/dist/web.d.mts +9 -1
- package/dist/web.d.ts +9 -1
- package/dist/web.js +18 -8
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +18 -8
- package/dist/web.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -184,6 +184,13 @@ interface RateLimitData {
|
|
|
184
184
|
* The route being hit in this request
|
|
185
185
|
*/
|
|
186
186
|
route: string;
|
|
187
|
+
/**
|
|
188
|
+
* The scope of the rate limit that was hit.
|
|
189
|
+
*
|
|
190
|
+
* This can be `user` for rate limits that are per client, `global` for rate limits that affect all clients or `shared` for rate limits that
|
|
191
|
+
* are shared per resource.
|
|
192
|
+
*/
|
|
193
|
+
scope: 'global' | 'shared' | 'user';
|
|
187
194
|
/**
|
|
188
195
|
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
|
189
196
|
* can be retried
|
|
@@ -728,7 +735,8 @@ declare class RateLimitError extends Error implements RateLimitData {
|
|
|
728
735
|
global: boolean;
|
|
729
736
|
retryAfter: number;
|
|
730
737
|
sublimitTimeout: number;
|
|
731
|
-
|
|
738
|
+
scope: RateLimitData['scope'];
|
|
739
|
+
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
|
732
740
|
/**
|
|
733
741
|
* The name of the error
|
|
734
742
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -184,6 +184,13 @@ interface RateLimitData {
|
|
|
184
184
|
* The route being hit in this request
|
|
185
185
|
*/
|
|
186
186
|
route: string;
|
|
187
|
+
/**
|
|
188
|
+
* The scope of the rate limit that was hit.
|
|
189
|
+
*
|
|
190
|
+
* This can be `user` for rate limits that are per client, `global` for rate limits that affect all clients or `shared` for rate limits that
|
|
191
|
+
* are shared per resource.
|
|
192
|
+
*/
|
|
193
|
+
scope: 'global' | 'shared' | 'user';
|
|
187
194
|
/**
|
|
188
195
|
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
|
189
196
|
* can be retried
|
|
@@ -728,7 +735,8 @@ declare class RateLimitError extends Error implements RateLimitData {
|
|
|
728
735
|
global: boolean;
|
|
729
736
|
retryAfter: number;
|
|
730
737
|
sublimitTimeout: number;
|
|
731
|
-
|
|
738
|
+
scope: RateLimitData['scope'];
|
|
739
|
+
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
|
732
740
|
/**
|
|
733
741
|
* The name of the error
|
|
734
742
|
*/
|
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.
|
|
127
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.2.0-dev.1700136223-6df233de1)`;
|
|
128
128
|
var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
|
|
129
129
|
var DefaultRestOptions = {
|
|
130
130
|
agent: null,
|
|
@@ -184,6 +184,7 @@ var RateLimitError = class _RateLimitError extends Error {
|
|
|
184
184
|
global;
|
|
185
185
|
retryAfter;
|
|
186
186
|
sublimitTimeout;
|
|
187
|
+
scope;
|
|
187
188
|
constructor({
|
|
188
189
|
timeToReset,
|
|
189
190
|
limit,
|
|
@@ -194,7 +195,8 @@ var RateLimitError = class _RateLimitError extends Error {
|
|
|
194
195
|
majorParameter,
|
|
195
196
|
global,
|
|
196
197
|
retryAfter,
|
|
197
|
-
sublimitTimeout
|
|
198
|
+
sublimitTimeout,
|
|
199
|
+
scope
|
|
198
200
|
}) {
|
|
199
201
|
super();
|
|
200
202
|
this.timeToReset = timeToReset;
|
|
@@ -207,6 +209,7 @@ var RateLimitError = class _RateLimitError extends Error {
|
|
|
207
209
|
this.global = global;
|
|
208
210
|
this.retryAfter = retryAfter;
|
|
209
211
|
this.sublimitTimeout = sublimitTimeout;
|
|
212
|
+
this.scope = scope;
|
|
210
213
|
}
|
|
211
214
|
/**
|
|
212
215
|
* The name of the error
|
|
@@ -788,6 +791,7 @@ var BurstHandler = class {
|
|
|
788
791
|
return res;
|
|
789
792
|
} else if (status === 429) {
|
|
790
793
|
const isGlobal = res.headers.has("X-RateLimit-Global");
|
|
794
|
+
const scope = res.headers.get("X-RateLimit-Scope") ?? "user";
|
|
791
795
|
await onRateLimit(this.manager, {
|
|
792
796
|
global: isGlobal,
|
|
793
797
|
method,
|
|
@@ -798,7 +802,8 @@ var BurstHandler = class {
|
|
|
798
802
|
limit: Number.POSITIVE_INFINITY,
|
|
799
803
|
timeToReset: retryAfter,
|
|
800
804
|
retryAfter,
|
|
801
|
-
sublimitTimeout: 0
|
|
805
|
+
sublimitTimeout: 0,
|
|
806
|
+
scope
|
|
802
807
|
});
|
|
803
808
|
this.debug(
|
|
804
809
|
[
|
|
@@ -811,7 +816,8 @@ var BurstHandler = class {
|
|
|
811
816
|
` Hash : ${this.hash}`,
|
|
812
817
|
` Limit : ${Number.POSITIVE_INFINITY}`,
|
|
813
818
|
` Retry After : ${retryAfter}ms`,
|
|
814
|
-
` Sublimit : None
|
|
819
|
+
` Sublimit : None`,
|
|
820
|
+
` Scope : ${scope}`
|
|
815
821
|
].join("\n")
|
|
816
822
|
);
|
|
817
823
|
await sleep(retryAfter);
|
|
@@ -994,7 +1000,8 @@ var SequentialHandler = class {
|
|
|
994
1000
|
limit: limit2,
|
|
995
1001
|
timeToReset: timeout,
|
|
996
1002
|
retryAfter: timeout,
|
|
997
|
-
sublimitTimeout: 0
|
|
1003
|
+
sublimitTimeout: 0,
|
|
1004
|
+
scope: "user"
|
|
998
1005
|
};
|
|
999
1006
|
this.manager.emit("rateLimited" /* RateLimited */, rateLimitData);
|
|
1000
1007
|
await onRateLimit(this.manager, rateLimitData);
|
|
@@ -1022,6 +1029,7 @@ var SequentialHandler = class {
|
|
|
1022
1029
|
const reset = res.headers.get("X-RateLimit-Reset-After");
|
|
1023
1030
|
const hash = res.headers.get("X-RateLimit-Bucket");
|
|
1024
1031
|
const retry = res.headers.get("Retry-After");
|
|
1032
|
+
const scope = res.headers.get("X-RateLimit-Scope") ?? "user";
|
|
1025
1033
|
this.limit = limit ? Number(limit) : Number.POSITIVE_INFINITY;
|
|
1026
1034
|
this.remaining = remaining ? Number(remaining) : 1;
|
|
1027
1035
|
this.reset = reset ? Number(reset) * 1e3 + Date.now() + this.manager.options.offset : Date.now();
|
|
@@ -1071,7 +1079,8 @@ var SequentialHandler = class {
|
|
|
1071
1079
|
limit: limit2,
|
|
1072
1080
|
timeToReset: timeout,
|
|
1073
1081
|
retryAfter,
|
|
1074
|
-
sublimitTimeout: sublimitTimeout ?? 0
|
|
1082
|
+
sublimitTimeout: sublimitTimeout ?? 0,
|
|
1083
|
+
scope
|
|
1075
1084
|
});
|
|
1076
1085
|
this.debug(
|
|
1077
1086
|
[
|
|
@@ -1084,7 +1093,8 @@ var SequentialHandler = class {
|
|
|
1084
1093
|
` Hash : ${this.hash}`,
|
|
1085
1094
|
` Limit : ${limit2}`,
|
|
1086
1095
|
` Retry After : ${retryAfter}ms`,
|
|
1087
|
-
` Sublimit : ${sublimitTimeout ? `${sublimitTimeout}ms` : "None"}
|
|
1096
|
+
` Sublimit : ${sublimitTimeout ? `${sublimitTimeout}ms` : "None"}`,
|
|
1097
|
+
` Scope : ${scope}`
|
|
1088
1098
|
].join("\n")
|
|
1089
1099
|
);
|
|
1090
1100
|
if (sublimitTimeout) {
|
|
@@ -1432,7 +1442,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1432
1442
|
};
|
|
1433
1443
|
|
|
1434
1444
|
// src/shared.ts
|
|
1435
|
-
var version = "2.
|
|
1445
|
+
var version = "2.2.0-dev.1700136223-6df233de1";
|
|
1436
1446
|
|
|
1437
1447
|
// src/index.ts
|
|
1438
1448
|
globalThis.FormData ??= import_undici2.FormData;
|