@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/web.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/web.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/web.js CHANGED
@@ -61,7 +61,7 @@ var import_v102 = require("discord-api-types/v10");
61
61
  // src/lib/utils/constants.ts
62
62
  var import_util = require("@discordjs/util");
63
63
  var import_v10 = require("discord-api-types/v10");
64
- var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.5.1)`;
64
+ var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.6.0)`;
65
65
  var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
66
66
  var DefaultRestOptions = {
67
67
  agent: null,
@@ -477,6 +477,16 @@ var CDN = class {
477
477
  soundboardSound(soundId) {
478
478
  return `${this.cdn}${import_v102.CDNRoutes.soundboardSound(soundId)}`;
479
479
  }
480
+ /**
481
+ * Generates a URL for a guild tag badge.
482
+ *
483
+ * @param guildId - The guild id
484
+ * @param badgeHash - The hash of the badge
485
+ * @param options - Optional options for the badge
486
+ */
487
+ guildTagBadge(guildId, badgeHash, options) {
488
+ return this.makeURL(`/guild-tag-badges/${guildId}/${badgeHash}`, options);
489
+ }
480
490
  /**
481
491
  * Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
482
492
  *
@@ -497,7 +507,8 @@ var CDN = class {
497
507
  allowedExtensions = ALLOWED_EXTENSIONS,
498
508
  base = this.cdn,
499
509
  extension = "webp",
500
- size
510
+ size,
511
+ animated
501
512
  } = {}) {
502
513
  extension = String(extension).toLowerCase();
503
514
  if (!allowedExtensions.includes(extension)) {
@@ -509,6 +520,9 @@ Must be one of: ${allowedExtensions.join(", ")}`);
509
520
  Must be one of: ${ALLOWED_SIZES.join(", ")}`);
510
521
  }
511
522
  const url = new URL(`${base}${route}.${extension}`);
523
+ if (animated !== void 0) {
524
+ url.searchParams.set("animated", String(animated));
525
+ }
512
526
  if (size) {
513
527
  url.searchParams.set("size", String(size));
514
528
  }
@@ -1403,7 +1417,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
1403
1417
  };
1404
1418
 
1405
1419
  // src/shared.ts
1406
- var version = "2.5.1";
1420
+ var version = "2.6.0";
1407
1421
 
1408
1422
  // src/web.ts
1409
1423
  setDefaultStrategy(fetch);