@discordjs/rest 3.0.0-dev.1748174699-c1f5bb2fb → 3.0.0-dev.1748347527-2c35084ec
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 +20 -38
- package/dist/index.d.ts +20 -38
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -7
- package/dist/index.mjs.map +1 -1
- package/dist/web.d.mts +20 -38
- package/dist/web.d.ts +20 -38
- package/dist/web.js +10 -7
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +10 -7
- package/dist/web.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -371,8 +371,6 @@ declare enum RequestMethod {
|
|
|
371
371
|
type RouteLike = `/${string}`;
|
|
372
372
|
/**
|
|
373
373
|
* Internal request options
|
|
374
|
-
*
|
|
375
|
-
* @internal
|
|
376
374
|
*/
|
|
377
375
|
interface InternalRequest extends RequestData {
|
|
378
376
|
fullRoute: RouteLike;
|
|
@@ -383,8 +381,6 @@ interface HandlerRequestData extends Pick<InternalRequest, 'body' | 'files' | 's
|
|
|
383
381
|
}
|
|
384
382
|
/**
|
|
385
383
|
* Parsed route data for an endpoint
|
|
386
|
-
*
|
|
387
|
-
* @internal
|
|
388
384
|
*/
|
|
389
385
|
interface RouteData {
|
|
390
386
|
bucketRoute: string;
|
|
@@ -393,8 +389,6 @@ interface RouteData {
|
|
|
393
389
|
}
|
|
394
390
|
/**
|
|
395
391
|
* Represents a hash and its associated fields
|
|
396
|
-
*
|
|
397
|
-
* @internal
|
|
398
392
|
*/
|
|
399
393
|
interface HashData {
|
|
400
394
|
lastAccess: number;
|
|
@@ -449,53 +443,42 @@ declare const BurstHandlerMajorIdKey = "burst";
|
|
|
449
443
|
declare const AUTH_UUID_NAMESPACE = "acc82a4c-f887-417b-a69c-f74096ff7e59";
|
|
450
444
|
|
|
451
445
|
/**
|
|
452
|
-
* The options used for image URLs
|
|
446
|
+
* The options used for image URLs.
|
|
453
447
|
*/
|
|
454
448
|
interface BaseImageURLOptions {
|
|
455
449
|
/**
|
|
456
|
-
* The extension to use for the image URL
|
|
450
|
+
* The extension to use for the image URL.
|
|
457
451
|
*
|
|
458
452
|
* @defaultValue `'webp'`
|
|
459
453
|
*/
|
|
460
454
|
extension?: ImageExtension;
|
|
461
455
|
/**
|
|
462
|
-
* The size specified in the image URL
|
|
456
|
+
* The size specified in the image URL.
|
|
463
457
|
*/
|
|
464
458
|
size?: ImageSize;
|
|
465
459
|
}
|
|
466
|
-
|
|
467
|
-
* The options used for image URLs with animated content
|
|
468
|
-
*/
|
|
469
|
-
interface ImageURLOptions extends BaseImageURLOptions {
|
|
460
|
+
interface EmojiURLOptionsWebp extends BaseImageURLOptions {
|
|
470
461
|
/**
|
|
471
|
-
* Whether
|
|
462
|
+
* Whether to use the `animated` query parameter.
|
|
472
463
|
*/
|
|
473
|
-
|
|
464
|
+
animated?: boolean;
|
|
465
|
+
extension?: 'webp';
|
|
466
|
+
}
|
|
467
|
+
interface EmojiURLOptionsNotWebp extends BaseImageURLOptions {
|
|
468
|
+
extension: Exclude<ImageExtension, 'webp'>;
|
|
474
469
|
}
|
|
475
470
|
/**
|
|
476
|
-
* The options
|
|
471
|
+
* The options used for emoji URLs.
|
|
477
472
|
*/
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* The base URL.
|
|
485
|
-
*
|
|
486
|
-
* @defaultValue `DefaultRestOptions.cdn`
|
|
487
|
-
*/
|
|
488
|
-
base?: string;
|
|
489
|
-
/**
|
|
490
|
-
* The extension to use for the image URL
|
|
491
|
-
*
|
|
492
|
-
* @defaultValue `'webp'`
|
|
493
|
-
*/
|
|
494
|
-
extension?: string | undefined;
|
|
473
|
+
type EmojiURLOptions = EmojiURLOptionsNotWebp | EmojiURLOptionsWebp;
|
|
474
|
+
/**
|
|
475
|
+
* The options used for image URLs that may be animated.
|
|
476
|
+
*/
|
|
477
|
+
interface ImageURLOptions extends BaseImageURLOptions {
|
|
495
478
|
/**
|
|
496
|
-
*
|
|
479
|
+
* Whether to prefer the static asset.
|
|
497
480
|
*/
|
|
498
|
-
|
|
481
|
+
forceStatic?: boolean;
|
|
499
482
|
}
|
|
500
483
|
/**
|
|
501
484
|
* The CDN link builder
|
|
@@ -571,10 +554,9 @@ declare class CDN {
|
|
|
571
554
|
* Generates an emoji's URL.
|
|
572
555
|
*
|
|
573
556
|
* @param emojiId - The emoji id
|
|
574
|
-
* @param animated - Whether the emoji is animated
|
|
575
557
|
* @param options - Optional options for the emoji
|
|
576
558
|
*/
|
|
577
|
-
emoji(emojiId: string,
|
|
559
|
+
emoji(emojiId: string, options?: Readonly<EmojiURLOptions>): string;
|
|
578
560
|
/**
|
|
579
561
|
* Generates a guild member avatar URL.
|
|
580
562
|
*
|
|
@@ -916,4 +898,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
|
|
916
898
|
*/
|
|
917
899
|
declare const version: string;
|
|
918
900
|
|
|
919
|
-
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordErrorData, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type
|
|
901
|
+
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type IHandler, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RawFile, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -371,8 +371,6 @@ declare enum RequestMethod {
|
|
|
371
371
|
type RouteLike = `/${string}`;
|
|
372
372
|
/**
|
|
373
373
|
* Internal request options
|
|
374
|
-
*
|
|
375
|
-
* @internal
|
|
376
374
|
*/
|
|
377
375
|
interface InternalRequest extends RequestData {
|
|
378
376
|
fullRoute: RouteLike;
|
|
@@ -383,8 +381,6 @@ interface HandlerRequestData extends Pick<InternalRequest, 'body' | 'files' | 's
|
|
|
383
381
|
}
|
|
384
382
|
/**
|
|
385
383
|
* Parsed route data for an endpoint
|
|
386
|
-
*
|
|
387
|
-
* @internal
|
|
388
384
|
*/
|
|
389
385
|
interface RouteData {
|
|
390
386
|
bucketRoute: string;
|
|
@@ -393,8 +389,6 @@ interface RouteData {
|
|
|
393
389
|
}
|
|
394
390
|
/**
|
|
395
391
|
* Represents a hash and its associated fields
|
|
396
|
-
*
|
|
397
|
-
* @internal
|
|
398
392
|
*/
|
|
399
393
|
interface HashData {
|
|
400
394
|
lastAccess: number;
|
|
@@ -449,53 +443,42 @@ declare const BurstHandlerMajorIdKey = "burst";
|
|
|
449
443
|
declare const AUTH_UUID_NAMESPACE = "acc82a4c-f887-417b-a69c-f74096ff7e59";
|
|
450
444
|
|
|
451
445
|
/**
|
|
452
|
-
* The options used for image URLs
|
|
446
|
+
* The options used for image URLs.
|
|
453
447
|
*/
|
|
454
448
|
interface BaseImageURLOptions {
|
|
455
449
|
/**
|
|
456
|
-
* The extension to use for the image URL
|
|
450
|
+
* The extension to use for the image URL.
|
|
457
451
|
*
|
|
458
452
|
* @defaultValue `'webp'`
|
|
459
453
|
*/
|
|
460
454
|
extension?: ImageExtension;
|
|
461
455
|
/**
|
|
462
|
-
* The size specified in the image URL
|
|
456
|
+
* The size specified in the image URL.
|
|
463
457
|
*/
|
|
464
458
|
size?: ImageSize;
|
|
465
459
|
}
|
|
466
|
-
|
|
467
|
-
* The options used for image URLs with animated content
|
|
468
|
-
*/
|
|
469
|
-
interface ImageURLOptions extends BaseImageURLOptions {
|
|
460
|
+
interface EmojiURLOptionsWebp extends BaseImageURLOptions {
|
|
470
461
|
/**
|
|
471
|
-
* Whether
|
|
462
|
+
* Whether to use the `animated` query parameter.
|
|
472
463
|
*/
|
|
473
|
-
|
|
464
|
+
animated?: boolean;
|
|
465
|
+
extension?: 'webp';
|
|
466
|
+
}
|
|
467
|
+
interface EmojiURLOptionsNotWebp extends BaseImageURLOptions {
|
|
468
|
+
extension: Exclude<ImageExtension, 'webp'>;
|
|
474
469
|
}
|
|
475
470
|
/**
|
|
476
|
-
* The options
|
|
471
|
+
* The options used for emoji URLs.
|
|
477
472
|
*/
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* The base URL.
|
|
485
|
-
*
|
|
486
|
-
* @defaultValue `DefaultRestOptions.cdn`
|
|
487
|
-
*/
|
|
488
|
-
base?: string;
|
|
489
|
-
/**
|
|
490
|
-
* The extension to use for the image URL
|
|
491
|
-
*
|
|
492
|
-
* @defaultValue `'webp'`
|
|
493
|
-
*/
|
|
494
|
-
extension?: string | undefined;
|
|
473
|
+
type EmojiURLOptions = EmojiURLOptionsNotWebp | EmojiURLOptionsWebp;
|
|
474
|
+
/**
|
|
475
|
+
* The options used for image URLs that may be animated.
|
|
476
|
+
*/
|
|
477
|
+
interface ImageURLOptions extends BaseImageURLOptions {
|
|
495
478
|
/**
|
|
496
|
-
*
|
|
479
|
+
* Whether to prefer the static asset.
|
|
497
480
|
*/
|
|
498
|
-
|
|
481
|
+
forceStatic?: boolean;
|
|
499
482
|
}
|
|
500
483
|
/**
|
|
501
484
|
* The CDN link builder
|
|
@@ -571,10 +554,9 @@ declare class CDN {
|
|
|
571
554
|
* Generates an emoji's URL.
|
|
572
555
|
*
|
|
573
556
|
* @param emojiId - The emoji id
|
|
574
|
-
* @param animated - Whether the emoji is animated
|
|
575
557
|
* @param options - Optional options for the emoji
|
|
576
558
|
*/
|
|
577
|
-
emoji(emojiId: string,
|
|
559
|
+
emoji(emojiId: string, options?: Readonly<EmojiURLOptions>): string;
|
|
578
560
|
/**
|
|
579
561
|
* Generates a guild member avatar URL.
|
|
580
562
|
*
|
|
@@ -916,4 +898,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
|
|
916
898
|
*/
|
|
917
899
|
declare const version: string;
|
|
918
900
|
|
|
919
|
-
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordErrorData, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type
|
|
901
|
+
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type IHandler, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RawFile, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
package/dist/index.js
CHANGED
|
@@ -127,7 +127,7 @@ var import_v102 = require("discord-api-types/v10");
|
|
|
127
127
|
// src/lib/utils/constants.ts
|
|
128
128
|
var import_util = require("@discordjs/util");
|
|
129
129
|
var import_v10 = require("discord-api-types/v10");
|
|
130
|
-
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-dev.
|
|
130
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-dev.1748347527-2c35084ec)`;
|
|
131
131
|
var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
|
|
132
132
|
var DefaultRestOptions = {
|
|
133
133
|
agent: null,
|
|
@@ -275,11 +275,10 @@ var CDN = class {
|
|
|
275
275
|
* Generates an emoji's URL.
|
|
276
276
|
*
|
|
277
277
|
* @param emojiId - The emoji id
|
|
278
|
-
* @param animated - Whether the emoji is animated
|
|
279
278
|
* @param options - Optional options for the emoji
|
|
280
279
|
*/
|
|
281
|
-
emoji(emojiId,
|
|
282
|
-
return this.
|
|
280
|
+
emoji(emojiId, options) {
|
|
281
|
+
return this.makeURL(`/emojis/${emojiId}`, options);
|
|
283
282
|
}
|
|
284
283
|
/**
|
|
285
284
|
* Generates a guild member avatar URL.
|
|
@@ -394,7 +393,7 @@ var CDN = class {
|
|
|
394
393
|
* @param options - Optional options for the link
|
|
395
394
|
*/
|
|
396
395
|
dynamicMakeURL(route, hash, { forceStatic = false, ...options } = {}) {
|
|
397
|
-
return this.makeURL(route, !forceStatic && hash.startsWith("a_") ? { ...options,
|
|
396
|
+
return this.makeURL(route, !forceStatic && hash.startsWith("a_") ? { ...options, animated: true } : options);
|
|
398
397
|
}
|
|
399
398
|
/**
|
|
400
399
|
* Constructs the URL for the resource
|
|
@@ -406,7 +405,8 @@ var CDN = class {
|
|
|
406
405
|
allowedExtensions = ALLOWED_EXTENSIONS,
|
|
407
406
|
base = this.cdn,
|
|
408
407
|
extension = "webp",
|
|
409
|
-
size
|
|
408
|
+
size,
|
|
409
|
+
animated
|
|
410
410
|
} = {}) {
|
|
411
411
|
extension = String(extension).toLowerCase();
|
|
412
412
|
if (!allowedExtensions.includes(extension)) {
|
|
@@ -418,6 +418,9 @@ Must be one of: ${allowedExtensions.join(", ")}`);
|
|
|
418
418
|
Must be one of: ${ALLOWED_SIZES.join(", ")}`);
|
|
419
419
|
}
|
|
420
420
|
const url = new URL(`${base}${route}.${extension}`);
|
|
421
|
+
if (animated !== void 0) {
|
|
422
|
+
url.searchParams.set("animated", String(animated));
|
|
423
|
+
}
|
|
421
424
|
if (size) {
|
|
422
425
|
url.searchParams.set("size", String(size));
|
|
423
426
|
}
|
|
@@ -1469,7 +1472,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1469
1472
|
};
|
|
1470
1473
|
|
|
1471
1474
|
// src/shared.ts
|
|
1472
|
-
var version = "3.0.0-dev.
|
|
1475
|
+
var version = "3.0.0-dev.1748347527-2c35084ec";
|
|
1473
1476
|
|
|
1474
1477
|
// src/index.ts
|
|
1475
1478
|
globalThis.FormData ??= import_undici2.FormData;
|