@discordjs/rest 2.5.1 → 2.6.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 CHANGED
@@ -446,26 +446,40 @@ declare const BurstHandlerMajorIdKey = "burst";
446
446
  declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
447
447
 
448
448
  /**
449
- * The options used for image URLs
449
+ * The options used for image URLs.
450
450
  */
451
451
  interface BaseImageURLOptions {
452
452
  /**
453
- * The extension to use for the image URL
453
+ * The extension to use for the image URL.
454
454
  *
455
455
  * @defaultValue `'webp'`
456
456
  */
457
457
  extension?: ImageExtension;
458
458
  /**
459
- * The size specified in the image URL
459
+ * The size specified in the image URL.
460
460
  */
461
461
  size?: ImageSize;
462
462
  }
463
+ interface EmojiURLOptionsWebp extends BaseImageURLOptions {
464
+ /**
465
+ * Whether to use the `animated` query parameter.
466
+ */
467
+ animated?: boolean;
468
+ extension?: 'webp';
469
+ }
470
+ interface EmojiURLOptionsNotWebp extends BaseImageURLOptions {
471
+ extension: Exclude<ImageExtension, 'webp'>;
472
+ }
463
473
  /**
464
- * The options used for image URLs with animated content
474
+ * The options used for emoji URLs.
475
+ */
476
+ type EmojiURLOptions = EmojiURLOptionsNotWebp | EmojiURLOptionsWebp;
477
+ /**
478
+ * The options used for image URLs that may be animated.
465
479
  */
466
480
  interface ImageURLOptions extends BaseImageURLOptions {
467
481
  /**
468
- * Whether or not to prefer the static version of an image asset.
482
+ * Whether to prefer the static asset.
469
483
  */
470
484
  forceStatic?: boolean;
471
485
  }
@@ -477,6 +491,10 @@ interface MakeURLOptions {
477
491
  * The allowed extensions that can be used
478
492
  */
479
493
  allowedExtensions?: readonly string[];
494
+ /**
495
+ * Whether to use the `animated` query parameter
496
+ */
497
+ animated?: boolean;
480
498
  /**
481
499
  * The base URL.
482
500
  *
@@ -579,7 +597,7 @@ declare class CDN {
579
597
  * @param emojiId - The emoji id
580
598
  * @param options - Optional options for the emoji
581
599
  */
582
- emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string;
600
+ emoji(emojiId: string, options?: Readonly<EmojiURLOptions>): string;
583
601
  /**
584
602
  * Generates an emoji's URL for an emoji.
585
603
  *
@@ -669,6 +687,14 @@ declare class CDN {
669
687
  * @param soundId - The soundboard sound id
670
688
  */
671
689
  soundboardSound(soundId: string): string;
690
+ /**
691
+ * Generates a URL for a guild tag badge.
692
+ *
693
+ * @param guildId - The guild id
694
+ * @param badgeHash - The hash of the badge
695
+ * @param options - Optional options for the badge
696
+ */
697
+ guildTagBadge(guildId: string, badgeHash: string, options?: Readonly<BaseImageURLOptions>): string;
672
698
  /**
673
699
  * Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
674
700
  *
@@ -929,4 +955,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
929
955
  */
930
956
  declare const version: string;
931
957
 
932
- export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordErrorData, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type MakeURLOptions, 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 };
958
+ export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordErrorData, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type MakeURLOptions, 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
@@ -446,26 +446,40 @@ declare const BurstHandlerMajorIdKey = "burst";
446
446
  declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
447
447
 
448
448
  /**
449
- * The options used for image URLs
449
+ * The options used for image URLs.
450
450
  */
451
451
  interface BaseImageURLOptions {
452
452
  /**
453
- * The extension to use for the image URL
453
+ * The extension to use for the image URL.
454
454
  *
455
455
  * @defaultValue `'webp'`
456
456
  */
457
457
  extension?: ImageExtension;
458
458
  /**
459
- * The size specified in the image URL
459
+ * The size specified in the image URL.
460
460
  */
461
461
  size?: ImageSize;
462
462
  }
463
+ interface EmojiURLOptionsWebp extends BaseImageURLOptions {
464
+ /**
465
+ * Whether to use the `animated` query parameter.
466
+ */
467
+ animated?: boolean;
468
+ extension?: 'webp';
469
+ }
470
+ interface EmojiURLOptionsNotWebp extends BaseImageURLOptions {
471
+ extension: Exclude<ImageExtension, 'webp'>;
472
+ }
463
473
  /**
464
- * The options used for image URLs with animated content
474
+ * The options used for emoji URLs.
475
+ */
476
+ type EmojiURLOptions = EmojiURLOptionsNotWebp | EmojiURLOptionsWebp;
477
+ /**
478
+ * The options used for image URLs that may be animated.
465
479
  */
466
480
  interface ImageURLOptions extends BaseImageURLOptions {
467
481
  /**
468
- * Whether or not to prefer the static version of an image asset.
482
+ * Whether to prefer the static asset.
469
483
  */
470
484
  forceStatic?: boolean;
471
485
  }
@@ -477,6 +491,10 @@ interface MakeURLOptions {
477
491
  * The allowed extensions that can be used
478
492
  */
479
493
  allowedExtensions?: readonly string[];
494
+ /**
495
+ * Whether to use the `animated` query parameter
496
+ */
497
+ animated?: boolean;
480
498
  /**
481
499
  * The base URL.
482
500
  *
@@ -579,7 +597,7 @@ declare class CDN {
579
597
  * @param emojiId - The emoji id
580
598
  * @param options - Optional options for the emoji
581
599
  */
582
- emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string;
600
+ emoji(emojiId: string, options?: Readonly<EmojiURLOptions>): string;
583
601
  /**
584
602
  * Generates an emoji's URL for an emoji.
585
603
  *
@@ -669,6 +687,14 @@ declare class CDN {
669
687
  * @param soundId - The soundboard sound id
670
688
  */
671
689
  soundboardSound(soundId: string): string;
690
+ /**
691
+ * Generates a URL for a guild tag badge.
692
+ *
693
+ * @param guildId - The guild id
694
+ * @param badgeHash - The hash of the badge
695
+ * @param options - Optional options for the badge
696
+ */
697
+ guildTagBadge(guildId: string, badgeHash: string, options?: Readonly<BaseImageURLOptions>): string;
672
698
  /**
673
699
  * Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
674
700
  *
@@ -929,4 +955,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
929
955
  */
930
956
  declare const version: string;
931
957
 
932
- export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordErrorData, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type MakeURLOptions, 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 };
958
+ export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordErrorData, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type MakeURLOptions, 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, 2.5.1)`;
130
+ var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.6.0)`;
131
131
  var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
132
132
  var DefaultRestOptions = {
133
133
  agent: null,
@@ -543,6 +543,16 @@ var CDN = class {
543
543
  soundboardSound(soundId) {
544
544
  return `${this.cdn}${import_v102.CDNRoutes.soundboardSound(soundId)}`;
545
545
  }
546
+ /**
547
+ * Generates a URL for a guild tag badge.
548
+ *
549
+ * @param guildId - The guild id
550
+ * @param badgeHash - The hash of the badge
551
+ * @param options - Optional options for the badge
552
+ */
553
+ guildTagBadge(guildId, badgeHash, options) {
554
+ return this.makeURL(`/guild-tag-badges/${guildId}/${badgeHash}`, options);
555
+ }
546
556
  /**
547
557
  * Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
548
558
  *
@@ -563,7 +573,8 @@ var CDN = class {
563
573
  allowedExtensions = ALLOWED_EXTENSIONS,
564
574
  base = this.cdn,
565
575
  extension = "webp",
566
- size
576
+ size,
577
+ animated
567
578
  } = {}) {
568
579
  extension = String(extension).toLowerCase();
569
580
  if (!allowedExtensions.includes(extension)) {
@@ -575,6 +586,9 @@ Must be one of: ${allowedExtensions.join(", ")}`);
575
586
  Must be one of: ${ALLOWED_SIZES.join(", ")}`);
576
587
  }
577
588
  const url = new URL(`${base}${route}.${extension}`);
589
+ if (animated !== void 0) {
590
+ url.searchParams.set("animated", String(animated));
591
+ }
578
592
  if (size) {
579
593
  url.searchParams.set("size", String(size));
580
594
  }
@@ -1469,7 +1483,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
1469
1483
  };
1470
1484
 
1471
1485
  // src/shared.ts
1472
- var version = "2.5.1";
1486
+ var version = "2.6.0";
1473
1487
 
1474
1488
  // src/index.ts
1475
1489
  globalThis.FormData ??= import_undici2.FormData;