@discordjs/rest 2.4.0-dev.1717589083-346d1be72 → 2.4.0-dev.1717891920-68031210f
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 +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +22 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -10
- package/dist/index.mjs.map +1 -1
- package/dist/web.d.mts +18 -3
- package/dist/web.d.ts +18 -3
- package/dist/web.js +22 -10
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +22 -10
- package/dist/web.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -107,6 +107,12 @@ interface RESTOptions {
|
|
|
107
107
|
* For example, to use global fetch, simply provide `makeRequest: fetch`
|
|
108
108
|
*/
|
|
109
109
|
makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
|
110
|
+
/**
|
|
111
|
+
* The media proxy path
|
|
112
|
+
*
|
|
113
|
+
* @defaultValue `'https://media.discordapp.net'`
|
|
114
|
+
*/
|
|
115
|
+
mediaProxy: string;
|
|
110
116
|
/**
|
|
111
117
|
* The extra offset to add to rate limits in milliseconds
|
|
112
118
|
*
|
|
@@ -409,6 +415,7 @@ declare const DefaultRestOptions: {
|
|
|
409
415
|
readonly hashLifetime: 86400000;
|
|
410
416
|
readonly handlerSweepInterval: 3600000;
|
|
411
417
|
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
|
418
|
+
readonly mediaProxy: "https://media.discordapp.net";
|
|
412
419
|
};
|
|
413
420
|
/**
|
|
414
421
|
* The events that the REST manager emits
|
|
@@ -470,6 +477,12 @@ interface MakeURLOptions {
|
|
|
470
477
|
* The allowed extensions that can be used
|
|
471
478
|
*/
|
|
472
479
|
allowedExtensions?: readonly string[];
|
|
480
|
+
/**
|
|
481
|
+
* The base URL.
|
|
482
|
+
*
|
|
483
|
+
* @defaultValue `DefaultRestOptions.cdn`
|
|
484
|
+
*/
|
|
485
|
+
base?: string;
|
|
473
486
|
/**
|
|
474
487
|
* The extension to use for the image URL
|
|
475
488
|
*
|
|
@@ -485,8 +498,9 @@ interface MakeURLOptions {
|
|
|
485
498
|
* The CDN link builder
|
|
486
499
|
*/
|
|
487
500
|
declare class CDN {
|
|
488
|
-
private readonly
|
|
489
|
-
|
|
501
|
+
private readonly cdn;
|
|
502
|
+
private readonly mediaProxy;
|
|
503
|
+
constructor(cdn?: string, mediaProxy?: string);
|
|
490
504
|
/**
|
|
491
505
|
* Generates an app asset URL for a client's asset.
|
|
492
506
|
*
|
|
@@ -622,7 +636,8 @@ declare class CDN {
|
|
|
622
636
|
* @param stickerId - The sticker id
|
|
623
637
|
* @param extension - The extension of the sticker
|
|
624
638
|
* @privateRemarks
|
|
625
|
-
* Stickers cannot have a `.webp` extension, so we default to a `.png
|
|
639
|
+
* Stickers cannot have a `.webp` extension, so we default to a `.png`.
|
|
640
|
+
* Sticker GIFs do not use the CDN base URL.
|
|
626
641
|
*/
|
|
627
642
|
sticker(stickerId: string, extension?: StickerExtension): string;
|
|
628
643
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -107,6 +107,12 @@ interface RESTOptions {
|
|
|
107
107
|
* For example, to use global fetch, simply provide `makeRequest: fetch`
|
|
108
108
|
*/
|
|
109
109
|
makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
|
110
|
+
/**
|
|
111
|
+
* The media proxy path
|
|
112
|
+
*
|
|
113
|
+
* @defaultValue `'https://media.discordapp.net'`
|
|
114
|
+
*/
|
|
115
|
+
mediaProxy: string;
|
|
110
116
|
/**
|
|
111
117
|
* The extra offset to add to rate limits in milliseconds
|
|
112
118
|
*
|
|
@@ -409,6 +415,7 @@ declare const DefaultRestOptions: {
|
|
|
409
415
|
readonly hashLifetime: 86400000;
|
|
410
416
|
readonly handlerSweepInterval: 3600000;
|
|
411
417
|
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
|
418
|
+
readonly mediaProxy: "https://media.discordapp.net";
|
|
412
419
|
};
|
|
413
420
|
/**
|
|
414
421
|
* The events that the REST manager emits
|
|
@@ -470,6 +477,12 @@ interface MakeURLOptions {
|
|
|
470
477
|
* The allowed extensions that can be used
|
|
471
478
|
*/
|
|
472
479
|
allowedExtensions?: readonly string[];
|
|
480
|
+
/**
|
|
481
|
+
* The base URL.
|
|
482
|
+
*
|
|
483
|
+
* @defaultValue `DefaultRestOptions.cdn`
|
|
484
|
+
*/
|
|
485
|
+
base?: string;
|
|
473
486
|
/**
|
|
474
487
|
* The extension to use for the image URL
|
|
475
488
|
*
|
|
@@ -485,8 +498,9 @@ interface MakeURLOptions {
|
|
|
485
498
|
* The CDN link builder
|
|
486
499
|
*/
|
|
487
500
|
declare class CDN {
|
|
488
|
-
private readonly
|
|
489
|
-
|
|
501
|
+
private readonly cdn;
|
|
502
|
+
private readonly mediaProxy;
|
|
503
|
+
constructor(cdn?: string, mediaProxy?: string);
|
|
490
504
|
/**
|
|
491
505
|
* Generates an app asset URL for a client's asset.
|
|
492
506
|
*
|
|
@@ -622,7 +636,8 @@ declare class CDN {
|
|
|
622
636
|
* @param stickerId - The sticker id
|
|
623
637
|
* @param extension - The extension of the sticker
|
|
624
638
|
* @privateRemarks
|
|
625
|
-
* Stickers cannot have a `.webp` extension, so we default to a `.png
|
|
639
|
+
* Stickers cannot have a `.webp` extension, so we default to a `.png`.
|
|
640
|
+
* Sticker GIFs do not use the CDN base URL.
|
|
626
641
|
*/
|
|
627
642
|
sticker(stickerId: string, extension?: StickerExtension): string;
|
|
628
643
|
/**
|
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.4.0-dev.
|
|
127
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.4.0-dev.1717891920-68031210f)`;
|
|
128
128
|
var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
|
|
129
129
|
var DefaultRestOptions = {
|
|
130
130
|
agent: null,
|
|
@@ -148,7 +148,8 @@ var DefaultRestOptions = {
|
|
|
148
148
|
// 1 Hour
|
|
149
149
|
async makeRequest(...args) {
|
|
150
150
|
return getDefaultStrategy()(...args);
|
|
151
|
-
}
|
|
151
|
+
},
|
|
152
|
+
mediaProxy: "https://media.discordapp.net"
|
|
152
153
|
};
|
|
153
154
|
var RESTEvents = /* @__PURE__ */ ((RESTEvents2) => {
|
|
154
155
|
RESTEvents2["Debug"] = "restDebug";
|
|
@@ -325,8 +326,9 @@ __name(normalizeRateLimitOffset, "normalizeRateLimitOffset");
|
|
|
325
326
|
// src/lib/CDN.ts
|
|
326
327
|
var deprecationEmittedForEmoji = false;
|
|
327
328
|
var CDN = class {
|
|
328
|
-
constructor(
|
|
329
|
-
this.
|
|
329
|
+
constructor(cdn = DefaultRestOptions.cdn, mediaProxy = DefaultRestOptions.mediaProxy) {
|
|
330
|
+
this.cdn = cdn;
|
|
331
|
+
this.mediaProxy = mediaProxy;
|
|
330
332
|
}
|
|
331
333
|
static {
|
|
332
334
|
__name(this, "CDN");
|
|
@@ -481,10 +483,15 @@ var CDN = class {
|
|
|
481
483
|
* @param stickerId - The sticker id
|
|
482
484
|
* @param extension - The extension of the sticker
|
|
483
485
|
* @privateRemarks
|
|
484
|
-
* Stickers cannot have a `.webp` extension, so we default to a `.png
|
|
486
|
+
* Stickers cannot have a `.webp` extension, so we default to a `.png`.
|
|
487
|
+
* Sticker GIFs do not use the CDN base URL.
|
|
485
488
|
*/
|
|
486
489
|
sticker(stickerId, extension = "png") {
|
|
487
|
-
return this.makeURL(`/stickers/${stickerId}`, {
|
|
490
|
+
return this.makeURL(`/stickers/${stickerId}`, {
|
|
491
|
+
allowedExtensions: ALLOWED_STICKER_EXTENSIONS,
|
|
492
|
+
base: extension === "gif" ? this.mediaProxy : this.cdn,
|
|
493
|
+
extension
|
|
494
|
+
});
|
|
488
495
|
}
|
|
489
496
|
/**
|
|
490
497
|
* Generates a sticker pack banner URL.
|
|
@@ -531,7 +538,12 @@ var CDN = class {
|
|
|
531
538
|
* @param route - The base cdn route
|
|
532
539
|
* @param options - The extension/size options for the link
|
|
533
540
|
*/
|
|
534
|
-
makeURL(route, {
|
|
541
|
+
makeURL(route, {
|
|
542
|
+
allowedExtensions = ALLOWED_EXTENSIONS,
|
|
543
|
+
base = this.cdn,
|
|
544
|
+
extension = "webp",
|
|
545
|
+
size
|
|
546
|
+
} = {}) {
|
|
535
547
|
extension = String(extension).toLowerCase();
|
|
536
548
|
if (!allowedExtensions.includes(extension)) {
|
|
537
549
|
throw new RangeError(`Invalid extension provided: ${extension}
|
|
@@ -541,7 +553,7 @@ Must be one of: ${allowedExtensions.join(", ")}`);
|
|
|
541
553
|
throw new RangeError(`Invalid size provided: ${size}
|
|
542
554
|
Must be one of: ${ALLOWED_SIZES.join(", ")}`);
|
|
543
555
|
}
|
|
544
|
-
const url = new URL(`${
|
|
556
|
+
const url = new URL(`${base}${route}.${extension}`);
|
|
545
557
|
if (size) {
|
|
546
558
|
url.searchParams.set("size", String(size));
|
|
547
559
|
}
|
|
@@ -1159,7 +1171,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1159
1171
|
options;
|
|
1160
1172
|
constructor(options = {}) {
|
|
1161
1173
|
super();
|
|
1162
|
-
this.cdn = new CDN(options.cdn ?? DefaultRestOptions.cdn);
|
|
1174
|
+
this.cdn = new CDN(options.cdn ?? DefaultRestOptions.cdn, options.mediaProxy ?? DefaultRestOptions.mediaProxy);
|
|
1163
1175
|
this.options = { ...DefaultRestOptions, ...options };
|
|
1164
1176
|
this.globalRemaining = Math.max(1, this.options.globalRequestsPerSecond);
|
|
1165
1177
|
this.agent = options.agent ?? null;
|
|
@@ -1436,7 +1448,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1436
1448
|
};
|
|
1437
1449
|
|
|
1438
1450
|
// src/shared.ts
|
|
1439
|
-
var version = "2.4.0-dev.
|
|
1451
|
+
var version = "2.4.0-dev.1717891920-68031210f";
|
|
1440
1452
|
|
|
1441
1453
|
// src/index.ts
|
|
1442
1454
|
globalThis.FormData ??= import_undici2.FormData;
|