@discordjs/rest 2.6.1 → 2.6.3

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
@@ -6,8 +6,8 @@ import { Collection } from '@discordjs/collection';
6
6
  import { Awaitable } from '@discordjs/util';
7
7
  import { ImageSize, Snowflake } from 'discord-api-types/v10';
8
8
  export { ImageSize } from 'discord-api-types/v10';
9
- import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
10
9
  import * as url from 'url';
10
+ import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
11
11
 
12
12
  interface IHandler {
13
13
  /**
@@ -928,14 +928,27 @@ declare class REST extends AsyncEventEmitter<RestEvents> {
928
928
  private static generateRouteData;
929
929
  }
930
930
 
931
+ /**
932
+ * Options for serializing URL search parameters.
933
+ */
934
+ interface MakeURLSearchParamsOptions {
935
+ /**
936
+ * How array values should be serialized.
937
+ *
938
+ * @defaultValue `'repeat'`
939
+ * @see {@link https://docs.discord.com/developers/reference#array-query-strings}
940
+ */
941
+ arrayFormat?: 'comma' | 'repeat';
942
+ }
931
943
  /**
932
944
  * Creates and populates an URLSearchParams instance from an object, stripping
933
945
  * out null and undefined values, while also coercing non-strings to strings.
934
946
  *
935
- * @param options - The options to use
947
+ * @param parameters - The parameters to use
948
+ * @param options - The options for serializing URL search parameters
936
949
  * @returns A populated URLSearchParams instance
937
950
  */
938
- declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
951
+ declare function makeURLSearchParams<ParametersType extends object>(parameters?: Readonly<ParametersType>, options?: MakeURLSearchParamsOptions): url.URLSearchParams;
939
952
  /**
940
953
  * Converts the response to usable data
941
954
  *
@@ -955,4 +968,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
955
968
  */
956
969
  declare const version: string;
957
970
 
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 };
971
+ 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 MakeURLSearchParamsOptions, 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
@@ -6,8 +6,8 @@ import { Collection } from '@discordjs/collection';
6
6
  import { Awaitable } from '@discordjs/util';
7
7
  import { ImageSize, Snowflake } from 'discord-api-types/v10';
8
8
  export { ImageSize } from 'discord-api-types/v10';
9
- import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
10
9
  import * as url from 'url';
10
+ import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
11
11
 
12
12
  interface IHandler {
13
13
  /**
@@ -928,14 +928,27 @@ declare class REST extends AsyncEventEmitter<RestEvents> {
928
928
  private static generateRouteData;
929
929
  }
930
930
 
931
+ /**
932
+ * Options for serializing URL search parameters.
933
+ */
934
+ interface MakeURLSearchParamsOptions {
935
+ /**
936
+ * How array values should be serialized.
937
+ *
938
+ * @defaultValue `'repeat'`
939
+ * @see {@link https://docs.discord.com/developers/reference#array-query-strings}
940
+ */
941
+ arrayFormat?: 'comma' | 'repeat';
942
+ }
931
943
  /**
932
944
  * Creates and populates an URLSearchParams instance from an object, stripping
933
945
  * out null and undefined values, while also coercing non-strings to strings.
934
946
  *
935
- * @param options - The options to use
947
+ * @param parameters - The parameters to use
948
+ * @param options - The options for serializing URL search parameters
936
949
  * @returns A populated URLSearchParams instance
937
950
  */
938
- declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
951
+ declare function makeURLSearchParams<ParametersType extends object>(parameters?: Readonly<ParametersType>, options?: MakeURLSearchParamsOptions): url.URLSearchParams;
939
952
  /**
940
953
  * Converts the response to usable data
941
954
  *
@@ -955,4 +968,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
955
968
  */
956
969
  declare const version: string;
957
970
 
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 };
971
+ 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 MakeURLSearchParamsOptions, 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.6.1)`;
64
+ var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.6.3)`;
65
65
  var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
66
66
  var DefaultRestOptions = {
67
67
  agent: null,
@@ -198,10 +198,29 @@ function serializeSearchParam(value) {
198
198
  }
199
199
  }
200
200
  __name(serializeSearchParam, "serializeSearchParam");
201
- function makeURLSearchParams(options) {
201
+ function makeURLSearchParams(parameters, options = {}) {
202
202
  const params = new URLSearchParams();
203
- if (!options) return params;
204
- for (const [key, value] of Object.entries(options)) {
203
+ if (!parameters) return params;
204
+ const { arrayFormat = "repeat" } = options;
205
+ for (const [key, value] of Object.entries(parameters)) {
206
+ if (Array.isArray(value)) {
207
+ const commaSeparatedElements = arrayFormat === "comma" ? [] : null;
208
+ for (const element of value) {
209
+ const serialized2 = serializeSearchParam(element);
210
+ if (serialized2 === null) {
211
+ continue;
212
+ }
213
+ if (commaSeparatedElements) {
214
+ commaSeparatedElements.push(serialized2);
215
+ } else {
216
+ params.append(key, serialized2);
217
+ }
218
+ }
219
+ if (commaSeparatedElements?.length) {
220
+ params.append(key, commaSeparatedElements.join(","));
221
+ }
222
+ continue;
223
+ }
205
224
  const serialized = serializeSearchParam(value);
206
225
  if (serialized !== null) params.append(key, serialized);
207
226
  }
@@ -277,6 +296,8 @@ var CDN = class {
277
296
  this.cdn = cdn;
278
297
  this.mediaProxy = mediaProxy;
279
298
  }
299
+ cdn;
300
+ mediaProxy;
280
301
  static {
281
302
  __name(this, "CDN");
282
303
  }
@@ -557,6 +578,11 @@ var DiscordAPIError = class _DiscordAPIError extends Error {
557
578
  this.url = url;
558
579
  this.requestBody = { files: bodyData.files, json: bodyData.body };
559
580
  }
581
+ rawError;
582
+ code;
583
+ status;
584
+ method;
585
+ url;
560
586
  static {
561
587
  __name(this, "DiscordAPIError");
562
588
  }
@@ -613,6 +639,9 @@ var HTTPError = class _HTTPError extends Error {
613
639
  this.url = url;
614
640
  this.requestBody = { files: bodyData.files, json: bodyData.body };
615
641
  }
642
+ status;
643
+ method;
644
+ url;
616
645
  static {
617
646
  __name(this, "HTTPError");
618
647
  }
@@ -713,6 +742,9 @@ var BurstHandler = class {
713
742
  this.majorParameter = majorParameter;
714
743
  this.id = `${hash}:${majorParameter}`;
715
744
  }
745
+ manager;
746
+ hash;
747
+ majorParameter;
716
748
  static {
717
749
  __name(this, "BurstHandler");
718
750
  }
@@ -820,6 +852,9 @@ var SequentialHandler = class {
820
852
  this.majorParameter = majorParameter;
821
853
  this.id = `${hash}:${majorParameter}`;
822
854
  }
855
+ manager;
856
+ hash;
857
+ majorParameter;
823
858
  static {
824
859
  __name(this, "SequentialHandler");
825
860
  }
@@ -1417,7 +1452,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
1417
1452
  };
1418
1453
 
1419
1454
  // src/shared.ts
1420
- var version = "2.6.1";
1455
+ var version = "2.6.3";
1421
1456
 
1422
1457
  // src/web.ts
1423
1458
  setDefaultStrategy(fetch);