@discordjs/rest 2.6.0 → 3.0.0-core-gateway-rl.1762368996-5fa92a1ea

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/README.md CHANGED
@@ -5,12 +5,13 @@
5
5
  </p>
6
6
  <br />
7
7
  <p>
8
- <a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
8
+ <a href="https://discord.gg/djs"><img src="https://img.shields.io/badge/join_us-on_discord-5865F2?logo=discord&logoColor=white" alt="Discord server" /></a>
9
9
  <a href="https://www.npmjs.com/package/@discordjs/rest"><img src="https://img.shields.io/npm/v/@discordjs/rest.svg?maxAge=3600" alt="npm version" /></a>
10
10
  <a href="https://www.npmjs.com/package/@discordjs/rest"><img src="https://img.shields.io/npm/dt/@discordjs/rest.svg?maxAge=3600" alt="npm downloads" /></a>
11
- <a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Tests status" /></a>
12
- <a href="https://github.com/discordjs/discord.js/commits/main/packages/rest" ><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Frest"></a>
13
- <a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=rest" alt="Code coverage" /></a>
11
+ <a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/tests.yml/badge.svg" alt="Tests status" /></a>
12
+ <a href="https://github.com/discordjs/discord.js/commits/main/packages/rest"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Frest" /></a>
13
+ <a href="https://opencollective.com/discordjs"><img src="https://img.shields.io/opencollective/backers/discordjs?maxAge=3600&logo=opencollective" alt="backers" /></a>
14
+ <a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=rest" alt="Code coverage" /></a>
14
15
  </p>
15
16
  <p>
16
17
  <a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
@@ -24,7 +25,7 @@
24
25
 
25
26
  ## Installation
26
27
 
27
- **Node.js 18 or newer is required.**
28
+ **Node.js 22.12.0 or newer is required.**
28
29
 
29
30
  ```sh
30
31
  npm install @discordjs/rest
@@ -109,7 +110,7 @@ try {
109
110
  - [Guide][guide] ([source][guide-source])
110
111
  Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
111
112
  - [discord.js Discord server][discord]
112
- - [Discord API Discord server][discord-api]
113
+ - [Discord Developers Discord server][discord-developers]
113
114
  - [GitHub][source]
114
115
  - [npm][npm]
115
116
  - [Related libraries][related-libs]
@@ -127,11 +128,11 @@ If you don't understand something in the documentation, you are experiencing pro
127
128
  [website]: https://discord.js.org
128
129
  [website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
129
130
  [documentation]: https://discord.js.org/docs/packages/rest/stable
130
- [guide]: https://discordjs.guide/
131
- [guide-source]: https://github.com/discordjs/guide
132
- [guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
131
+ [guide]: https://discordjs.guide
132
+ [guide-source]: https://github.com/discordjs/discord.js/tree/main/apps/guide
133
+ [guide-update]: https://discordjs.guide/legacy/additional-info/changes-in-v14
133
134
  [discord]: https://discord.gg/djs
134
- [discord-api]: https://discord.gg/discord-api
135
+ [discord-developers]: https://discord.gg/discord-developers
135
136
  [source]: https://github.com/discordjs/discord.js/tree/main/packages/rest
136
137
  [npm]: https://www.npmjs.com/package/@discordjs/rest
137
138
  [related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
package/dist/index.d.mts CHANGED
@@ -6,7 +6,7 @@ import { ReadableStream } from 'node:stream/web';
6
6
  import { Collection } from '@discordjs/collection';
7
7
  import { Awaitable } from '@discordjs/util';
8
8
  import * as undici from 'undici';
9
- import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
9
+ import { RequestInit, Response, BodyInit, Agent, Dispatcher } from 'undici';
10
10
  import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
11
11
 
12
12
  interface IHandler {
@@ -136,12 +136,18 @@ interface RESTOptions {
136
136
  * @defaultValue `3`
137
137
  */
138
138
  retries: number;
139
+ /**
140
+ * The time to exponentially add before retrying a 5xx or aborted request
141
+ *
142
+ * @defaultValue `0`
143
+ */
144
+ retryBackoff: GetRetryBackoffFunction | number;
139
145
  /**
140
146
  * The time to wait in milliseconds before a request is aborted
141
147
  *
142
148
  * @defaultValue `15_000`
143
149
  */
144
- timeout: number;
150
+ timeout: GetTimeoutFunction | number;
145
151
  /**
146
152
  * Extra information to add to the user agent
147
153
  *
@@ -221,6 +227,23 @@ type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>
221
227
  * A function that determines the rate limit offset for a given request.
222
228
  */
223
229
  type GetRateLimitOffsetFunction = (route: string) => number;
230
+ /**
231
+ * A function that determines the backoff for a retry for a given request.
232
+ *
233
+ * @param route - The route that has encountered a server-side error
234
+ * @param statusCode - The status code received or `null` if aborted
235
+ * @param retryCount - The number of retries that have been attempted so far. The first call will be `0`
236
+ * @param requestBody - The body that was sent with the request
237
+ * @returns The delay for the current request or `null` to throw an error instead of retrying
238
+ */
239
+ type GetRetryBackoffFunction = (route: string, statusCode: number | null, retryCount: number, requestBody: unknown) => number | null;
240
+ /**
241
+ * A function that determines the timeout for a given request.
242
+ *
243
+ * @param route - The route that is being processed
244
+ * @param body - The body that will be sent with the request
245
+ */
246
+ type GetTimeoutFunction = (route: string, body: unknown) => number;
224
247
  interface APIRequest {
225
248
  /**
226
249
  * The data that was used to form the body of this request
@@ -283,6 +306,18 @@ interface RawFile {
283
306
  */
284
307
  name: string;
285
308
  }
309
+ interface AuthData {
310
+ /**
311
+ * The authorization prefix to use for this request, useful if you use this with bearer tokens
312
+ *
313
+ * @defaultValue `REST.options.authPrefix`
314
+ */
315
+ prefix?: 'Bearer' | 'Bot';
316
+ /**
317
+ * The authorization token to use for this request
318
+ */
319
+ token: string;
320
+ }
286
321
  /**
287
322
  * Represents possible data to be given to an endpoint
288
323
  */
@@ -292,17 +327,13 @@ interface RequestData {
292
327
  */
293
328
  appendToFormData?: boolean;
294
329
  /**
295
- * If this request needs the `Authorization` header
330
+ * Alternate authorization data to use for this request only, or `false` to disable the Authorization header.
331
+ * When making a request to a route that includes a token (such as interactions or webhooks), set to `false`
332
+ * to avoid accidentally unsetting the instance token if a 401 is encountered.
296
333
  *
297
334
  * @defaultValue `true`
298
335
  */
299
- auth?: boolean;
300
- /**
301
- * The authorization prefix to use for this request, useful if you use this with bearer tokens
302
- *
303
- * @defaultValue `'Bot'`
304
- */
305
- authPrefix?: 'Bearer' | 'Bot';
336
+ auth?: AuthData | boolean | undefined;
306
337
  /**
307
338
  * The body to send to this request.
308
339
  * If providing as BodyInit, set `passThroughBody: true`
@@ -365,18 +396,16 @@ declare enum RequestMethod {
365
396
  type RouteLike = `/${string}`;
366
397
  /**
367
398
  * Internal request options
368
- *
369
- * @internal
370
399
  */
371
400
  interface InternalRequest extends RequestData {
372
401
  fullRoute: RouteLike;
373
402
  method: RequestMethod;
374
403
  }
375
- type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
404
+ interface HandlerRequestData extends Pick<InternalRequest, 'body' | 'files' | 'signal'> {
405
+ auth: boolean | string;
406
+ }
376
407
  /**
377
408
  * Parsed route data for an endpoint
378
- *
379
- * @internal
380
409
  */
381
410
  interface RouteData {
382
411
  bucketRoute: string;
@@ -385,8 +414,6 @@ interface RouteData {
385
414
  }
386
415
  /**
387
416
  * Represents a hash and its associated fields
388
- *
389
- * @internal
390
417
  */
391
418
  interface HashData {
392
419
  lastAccess: number;
@@ -409,6 +436,7 @@ declare const DefaultRestOptions: {
409
436
  readonly offset: 50;
410
437
  readonly rejectOnRateLimit: null;
411
438
  readonly retries: 3;
439
+ readonly retryBackoff: 0;
412
440
  readonly timeout: 15000;
413
441
  readonly userAgentAppendix: string;
414
442
  readonly version: "10";
@@ -438,12 +466,7 @@ declare const OverwrittenMimeTypes: {
438
466
  readonly 'image/apng': "image/png";
439
467
  };
440
468
  declare const BurstHandlerMajorIdKey = "burst";
441
- /**
442
- * Prefix for deprecation warnings.
443
- *
444
- * @internal
445
- */
446
- declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
469
+ declare const AUTH_UUID_NAMESPACE = "acc82a4c-f887-417b-a69c-f74096ff7e59";
447
470
 
448
471
  /**
449
472
  * The options used for image URLs.
@@ -484,33 +507,21 @@ interface ImageURLOptions extends BaseImageURLOptions {
484
507
  forceStatic?: boolean;
485
508
  }
486
509
  /**
487
- * The options to use when making a CDN URL
510
+ * Options for initializing the {@link CDN} class.
488
511
  */
489
- interface MakeURLOptions {
512
+ interface CDNOptions {
490
513
  /**
491
- * The allowed extensions that can be used
492
- */
493
- allowedExtensions?: readonly string[];
494
- /**
495
- * Whether to use the `animated` query parameter
496
- */
497
- animated?: boolean;
498
- /**
499
- * The base URL.
514
+ * The base URL for the CDN.
500
515
  *
501
516
  * @defaultValue `DefaultRestOptions.cdn`
502
517
  */
503
- base?: string;
518
+ cdn?: string | undefined;
504
519
  /**
505
- * The extension to use for the image URL
520
+ * The base URL for the media proxy.
506
521
  *
507
- * @defaultValue `'webp'`
522
+ * @defaultValue `DefaultRestOptions.mediaProxy`
508
523
  */
509
- extension?: string | undefined;
510
- /**
511
- * The size specified in the image URL
512
- */
513
- size?: ImageSize;
524
+ mediaProxy?: string | undefined;
514
525
  }
515
526
  /**
516
527
  * The CDN link builder
@@ -518,7 +529,7 @@ interface MakeURLOptions {
518
529
  declare class CDN {
519
530
  private readonly cdn;
520
531
  private readonly mediaProxy;
521
- constructor(cdn?: string, mediaProxy?: string);
532
+ constructor({ cdn, mediaProxy }?: CDNOptions);
522
533
  /**
523
534
  * Generates an app asset URL for a client's asset.
524
535
  *
@@ -549,15 +560,6 @@ declare class CDN {
549
560
  * @param asset - The avatar decoration hash
550
561
  */
551
562
  avatarDecoration(asset: string): string;
552
- /**
553
- * Generates a user avatar decoration URL.
554
- *
555
- * @deprecated This overload is deprecated. Pass a hash instead.
556
- * @param userId - The id of the user
557
- * @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
558
- * @param options - Optional options for the avatar decoration
559
- */
560
- avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
561
563
  /**
562
564
  * Generates a banner URL, e.g. for a user or a guild.
563
565
  *
@@ -592,20 +594,12 @@ declare class CDN {
592
594
  */
593
595
  discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
594
596
  /**
595
- * Generates an emoji's URL for an emoji.
597
+ * Generates an emoji's URL.
596
598
  *
597
599
  * @param emojiId - The emoji id
598
600
  * @param options - Optional options for the emoji
599
601
  */
600
602
  emoji(emojiId: string, options?: Readonly<EmojiURLOptions>): string;
601
- /**
602
- * Generates an emoji's URL for an emoji.
603
- *
604
- * @param emojiId - The emoji id
605
- * @param extension - The extension of the emoji
606
- * @deprecated This overload is deprecated. Pass an object containing the extension instead.
607
- */
608
- emoji(emojiId: string, extension?: ImageExtension): string;
609
603
  /**
610
604
  * Generates a guild member avatar URL.
611
605
  *
@@ -749,8 +743,8 @@ declare class DiscordAPIError extends Error {
749
743
  * @param rawError - The error reported by Discord
750
744
  * @param code - The error code reported by Discord
751
745
  * @param status - The status code of the response
752
- * @param method - The method of the request that erred
753
- * @param url - The url of the request that erred
746
+ * @param method - The method of the request that errored
747
+ * @param url - The url of the request that errored
754
748
  * @param bodyData - The unparsed data for the request that errored
755
749
  */
756
750
  constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
@@ -774,8 +768,8 @@ declare class HTTPError extends Error {
774
768
  /**
775
769
  * @param status - The status code of the response
776
770
  * @param statusText - The status text of the response
777
- * @param method - The method of the request that erred
778
- * @param url - The url of the request that erred
771
+ * @param method - The method of the request that errored
772
+ * @param url - The url of the request that errored
779
773
  * @param bodyData - The unparsed data for the request that errored
780
774
  */
781
775
  constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
@@ -793,7 +787,7 @@ declare class RateLimitError extends Error implements RateLimitData {
793
787
  retryAfter: number;
794
788
  sublimitTimeout: number;
795
789
  scope: RateLimitData['scope'];
796
- constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
790
+ constructor(data: RateLimitData);
797
791
  /**
798
792
  * The name of the error
799
793
  */
@@ -955,4 +949,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
955
949
  */
956
950
  declare const version: string;
957
951
 
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 };
952
+ export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, type CDNOptions, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, type GetRetryBackoffFunction, type GetTimeoutFunction, 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
@@ -6,7 +6,7 @@ import { ReadableStream } from 'node:stream/web';
6
6
  import { Collection } from '@discordjs/collection';
7
7
  import { Awaitable } from '@discordjs/util';
8
8
  import * as undici from 'undici';
9
- import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
9
+ import { RequestInit, Response, BodyInit, Agent, Dispatcher } from 'undici';
10
10
  import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
11
11
 
12
12
  interface IHandler {
@@ -136,12 +136,18 @@ interface RESTOptions {
136
136
  * @defaultValue `3`
137
137
  */
138
138
  retries: number;
139
+ /**
140
+ * The time to exponentially add before retrying a 5xx or aborted request
141
+ *
142
+ * @defaultValue `0`
143
+ */
144
+ retryBackoff: GetRetryBackoffFunction | number;
139
145
  /**
140
146
  * The time to wait in milliseconds before a request is aborted
141
147
  *
142
148
  * @defaultValue `15_000`
143
149
  */
144
- timeout: number;
150
+ timeout: GetTimeoutFunction | number;
145
151
  /**
146
152
  * Extra information to add to the user agent
147
153
  *
@@ -221,6 +227,23 @@ type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>
221
227
  * A function that determines the rate limit offset for a given request.
222
228
  */
223
229
  type GetRateLimitOffsetFunction = (route: string) => number;
230
+ /**
231
+ * A function that determines the backoff for a retry for a given request.
232
+ *
233
+ * @param route - The route that has encountered a server-side error
234
+ * @param statusCode - The status code received or `null` if aborted
235
+ * @param retryCount - The number of retries that have been attempted so far. The first call will be `0`
236
+ * @param requestBody - The body that was sent with the request
237
+ * @returns The delay for the current request or `null` to throw an error instead of retrying
238
+ */
239
+ type GetRetryBackoffFunction = (route: string, statusCode: number | null, retryCount: number, requestBody: unknown) => number | null;
240
+ /**
241
+ * A function that determines the timeout for a given request.
242
+ *
243
+ * @param route - The route that is being processed
244
+ * @param body - The body that will be sent with the request
245
+ */
246
+ type GetTimeoutFunction = (route: string, body: unknown) => number;
224
247
  interface APIRequest {
225
248
  /**
226
249
  * The data that was used to form the body of this request
@@ -283,6 +306,18 @@ interface RawFile {
283
306
  */
284
307
  name: string;
285
308
  }
309
+ interface AuthData {
310
+ /**
311
+ * The authorization prefix to use for this request, useful if you use this with bearer tokens
312
+ *
313
+ * @defaultValue `REST.options.authPrefix`
314
+ */
315
+ prefix?: 'Bearer' | 'Bot';
316
+ /**
317
+ * The authorization token to use for this request
318
+ */
319
+ token: string;
320
+ }
286
321
  /**
287
322
  * Represents possible data to be given to an endpoint
288
323
  */
@@ -292,17 +327,13 @@ interface RequestData {
292
327
  */
293
328
  appendToFormData?: boolean;
294
329
  /**
295
- * If this request needs the `Authorization` header
330
+ * Alternate authorization data to use for this request only, or `false` to disable the Authorization header.
331
+ * When making a request to a route that includes a token (such as interactions or webhooks), set to `false`
332
+ * to avoid accidentally unsetting the instance token if a 401 is encountered.
296
333
  *
297
334
  * @defaultValue `true`
298
335
  */
299
- auth?: boolean;
300
- /**
301
- * The authorization prefix to use for this request, useful if you use this with bearer tokens
302
- *
303
- * @defaultValue `'Bot'`
304
- */
305
- authPrefix?: 'Bearer' | 'Bot';
336
+ auth?: AuthData | boolean | undefined;
306
337
  /**
307
338
  * The body to send to this request.
308
339
  * If providing as BodyInit, set `passThroughBody: true`
@@ -365,18 +396,16 @@ declare enum RequestMethod {
365
396
  type RouteLike = `/${string}`;
366
397
  /**
367
398
  * Internal request options
368
- *
369
- * @internal
370
399
  */
371
400
  interface InternalRequest extends RequestData {
372
401
  fullRoute: RouteLike;
373
402
  method: RequestMethod;
374
403
  }
375
- type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
404
+ interface HandlerRequestData extends Pick<InternalRequest, 'body' | 'files' | 'signal'> {
405
+ auth: boolean | string;
406
+ }
376
407
  /**
377
408
  * Parsed route data for an endpoint
378
- *
379
- * @internal
380
409
  */
381
410
  interface RouteData {
382
411
  bucketRoute: string;
@@ -385,8 +414,6 @@ interface RouteData {
385
414
  }
386
415
  /**
387
416
  * Represents a hash and its associated fields
388
- *
389
- * @internal
390
417
  */
391
418
  interface HashData {
392
419
  lastAccess: number;
@@ -409,6 +436,7 @@ declare const DefaultRestOptions: {
409
436
  readonly offset: 50;
410
437
  readonly rejectOnRateLimit: null;
411
438
  readonly retries: 3;
439
+ readonly retryBackoff: 0;
412
440
  readonly timeout: 15000;
413
441
  readonly userAgentAppendix: string;
414
442
  readonly version: "10";
@@ -438,12 +466,7 @@ declare const OverwrittenMimeTypes: {
438
466
  readonly 'image/apng': "image/png";
439
467
  };
440
468
  declare const BurstHandlerMajorIdKey = "burst";
441
- /**
442
- * Prefix for deprecation warnings.
443
- *
444
- * @internal
445
- */
446
- declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
469
+ declare const AUTH_UUID_NAMESPACE = "acc82a4c-f887-417b-a69c-f74096ff7e59";
447
470
 
448
471
  /**
449
472
  * The options used for image URLs.
@@ -484,33 +507,21 @@ interface ImageURLOptions extends BaseImageURLOptions {
484
507
  forceStatic?: boolean;
485
508
  }
486
509
  /**
487
- * The options to use when making a CDN URL
510
+ * Options for initializing the {@link CDN} class.
488
511
  */
489
- interface MakeURLOptions {
512
+ interface CDNOptions {
490
513
  /**
491
- * The allowed extensions that can be used
492
- */
493
- allowedExtensions?: readonly string[];
494
- /**
495
- * Whether to use the `animated` query parameter
496
- */
497
- animated?: boolean;
498
- /**
499
- * The base URL.
514
+ * The base URL for the CDN.
500
515
  *
501
516
  * @defaultValue `DefaultRestOptions.cdn`
502
517
  */
503
- base?: string;
518
+ cdn?: string | undefined;
504
519
  /**
505
- * The extension to use for the image URL
520
+ * The base URL for the media proxy.
506
521
  *
507
- * @defaultValue `'webp'`
522
+ * @defaultValue `DefaultRestOptions.mediaProxy`
508
523
  */
509
- extension?: string | undefined;
510
- /**
511
- * The size specified in the image URL
512
- */
513
- size?: ImageSize;
524
+ mediaProxy?: string | undefined;
514
525
  }
515
526
  /**
516
527
  * The CDN link builder
@@ -518,7 +529,7 @@ interface MakeURLOptions {
518
529
  declare class CDN {
519
530
  private readonly cdn;
520
531
  private readonly mediaProxy;
521
- constructor(cdn?: string, mediaProxy?: string);
532
+ constructor({ cdn, mediaProxy }?: CDNOptions);
522
533
  /**
523
534
  * Generates an app asset URL for a client's asset.
524
535
  *
@@ -549,15 +560,6 @@ declare class CDN {
549
560
  * @param asset - The avatar decoration hash
550
561
  */
551
562
  avatarDecoration(asset: string): string;
552
- /**
553
- * Generates a user avatar decoration URL.
554
- *
555
- * @deprecated This overload is deprecated. Pass a hash instead.
556
- * @param userId - The id of the user
557
- * @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
558
- * @param options - Optional options for the avatar decoration
559
- */
560
- avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
561
563
  /**
562
564
  * Generates a banner URL, e.g. for a user or a guild.
563
565
  *
@@ -592,20 +594,12 @@ declare class CDN {
592
594
  */
593
595
  discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
594
596
  /**
595
- * Generates an emoji's URL for an emoji.
597
+ * Generates an emoji's URL.
596
598
  *
597
599
  * @param emojiId - The emoji id
598
600
  * @param options - Optional options for the emoji
599
601
  */
600
602
  emoji(emojiId: string, options?: Readonly<EmojiURLOptions>): string;
601
- /**
602
- * Generates an emoji's URL for an emoji.
603
- *
604
- * @param emojiId - The emoji id
605
- * @param extension - The extension of the emoji
606
- * @deprecated This overload is deprecated. Pass an object containing the extension instead.
607
- */
608
- emoji(emojiId: string, extension?: ImageExtension): string;
609
603
  /**
610
604
  * Generates a guild member avatar URL.
611
605
  *
@@ -749,8 +743,8 @@ declare class DiscordAPIError extends Error {
749
743
  * @param rawError - The error reported by Discord
750
744
  * @param code - The error code reported by Discord
751
745
  * @param status - The status code of the response
752
- * @param method - The method of the request that erred
753
- * @param url - The url of the request that erred
746
+ * @param method - The method of the request that errored
747
+ * @param url - The url of the request that errored
754
748
  * @param bodyData - The unparsed data for the request that errored
755
749
  */
756
750
  constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
@@ -774,8 +768,8 @@ declare class HTTPError extends Error {
774
768
  /**
775
769
  * @param status - The status code of the response
776
770
  * @param statusText - The status text of the response
777
- * @param method - The method of the request that erred
778
- * @param url - The url of the request that erred
771
+ * @param method - The method of the request that errored
772
+ * @param url - The url of the request that errored
779
773
  * @param bodyData - The unparsed data for the request that errored
780
774
  */
781
775
  constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
@@ -793,7 +787,7 @@ declare class RateLimitError extends Error implements RateLimitData {
793
787
  retryAfter: number;
794
788
  sublimitTimeout: number;
795
789
  scope: RateLimitData['scope'];
796
- constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
790
+ constructor(data: RateLimitData);
797
791
  /**
798
792
  * The name of the error
799
793
  */
@@ -955,4 +949,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
955
949
  */
956
950
  declare const version: string;
957
951
 
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 };
952
+ export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, type CDNOptions, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, type GetRetryBackoffFunction, type GetTimeoutFunction, 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 };