@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/README.md +10 -9
- package/dist/index.d.mts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +40 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -5
- package/dist/index.mjs.map +1 -1
- package/dist/web.d.mts +17 -4
- package/dist/web.d.ts +17 -4
- package/dist/web.js +40 -5
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +40 -5
- package/dist/web.mjs.map +1 -1
- package/package.json +7 -7
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/
|
|
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
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"
|
|
13
|
-
<a href="https://
|
|
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>
|
|
@@ -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
|
|
113
|
+
- [Discord Developers Discord server][discord-developers]
|
|
113
114
|
- [GitHub][source]
|
|
114
115
|
- [npm][npm]
|
|
115
116
|
- [Related libraries][related-libs]
|
|
@@ -127,12 +128,12 @@ 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
|
|
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-
|
|
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
|
-
[related-libs]: https://discord.com/developers/
|
|
138
|
+
[related-libs]: https://docs.discord.com/developers/developer-tools/community-resources#libraries
|
|
138
139
|
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
package/dist/index.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
|
|
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<
|
|
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/index.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
|
|
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<
|
|
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/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.6.
|
|
130
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.6.3)`;
|
|
131
131
|
var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
|
|
132
132
|
var DefaultRestOptions = {
|
|
133
133
|
agent: null,
|
|
@@ -264,10 +264,29 @@ function serializeSearchParam(value) {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
__name(serializeSearchParam, "serializeSearchParam");
|
|
267
|
-
function makeURLSearchParams(options) {
|
|
267
|
+
function makeURLSearchParams(parameters, options = {}) {
|
|
268
268
|
const params = new URLSearchParams();
|
|
269
|
-
if (!
|
|
270
|
-
|
|
269
|
+
if (!parameters) return params;
|
|
270
|
+
const { arrayFormat = "repeat" } = options;
|
|
271
|
+
for (const [key, value] of Object.entries(parameters)) {
|
|
272
|
+
if (Array.isArray(value)) {
|
|
273
|
+
const commaSeparatedElements = arrayFormat === "comma" ? [] : null;
|
|
274
|
+
for (const element of value) {
|
|
275
|
+
const serialized2 = serializeSearchParam(element);
|
|
276
|
+
if (serialized2 === null) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (commaSeparatedElements) {
|
|
280
|
+
commaSeparatedElements.push(serialized2);
|
|
281
|
+
} else {
|
|
282
|
+
params.append(key, serialized2);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (commaSeparatedElements?.length) {
|
|
286
|
+
params.append(key, commaSeparatedElements.join(","));
|
|
287
|
+
}
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
271
290
|
const serialized = serializeSearchParam(value);
|
|
272
291
|
if (serialized !== null) params.append(key, serialized);
|
|
273
292
|
}
|
|
@@ -343,6 +362,8 @@ var CDN = class {
|
|
|
343
362
|
this.cdn = cdn;
|
|
344
363
|
this.mediaProxy = mediaProxy;
|
|
345
364
|
}
|
|
365
|
+
cdn;
|
|
366
|
+
mediaProxy;
|
|
346
367
|
static {
|
|
347
368
|
__name(this, "CDN");
|
|
348
369
|
}
|
|
@@ -623,6 +644,11 @@ var DiscordAPIError = class _DiscordAPIError extends Error {
|
|
|
623
644
|
this.url = url;
|
|
624
645
|
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
|
625
646
|
}
|
|
647
|
+
rawError;
|
|
648
|
+
code;
|
|
649
|
+
status;
|
|
650
|
+
method;
|
|
651
|
+
url;
|
|
626
652
|
static {
|
|
627
653
|
__name(this, "DiscordAPIError");
|
|
628
654
|
}
|
|
@@ -679,6 +705,9 @@ var HTTPError = class _HTTPError extends Error {
|
|
|
679
705
|
this.url = url;
|
|
680
706
|
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
|
681
707
|
}
|
|
708
|
+
status;
|
|
709
|
+
method;
|
|
710
|
+
url;
|
|
682
711
|
static {
|
|
683
712
|
__name(this, "HTTPError");
|
|
684
713
|
}
|
|
@@ -779,6 +808,9 @@ var BurstHandler = class {
|
|
|
779
808
|
this.majorParameter = majorParameter;
|
|
780
809
|
this.id = `${hash}:${majorParameter}`;
|
|
781
810
|
}
|
|
811
|
+
manager;
|
|
812
|
+
hash;
|
|
813
|
+
majorParameter;
|
|
782
814
|
static {
|
|
783
815
|
__name(this, "BurstHandler");
|
|
784
816
|
}
|
|
@@ -886,6 +918,9 @@ var SequentialHandler = class {
|
|
|
886
918
|
this.majorParameter = majorParameter;
|
|
887
919
|
this.id = `${hash}:${majorParameter}`;
|
|
888
920
|
}
|
|
921
|
+
manager;
|
|
922
|
+
hash;
|
|
923
|
+
majorParameter;
|
|
889
924
|
static {
|
|
890
925
|
__name(this, "SequentialHandler");
|
|
891
926
|
}
|
|
@@ -1483,7 +1518,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1483
1518
|
};
|
|
1484
1519
|
|
|
1485
1520
|
// src/shared.ts
|
|
1486
|
-
var version = "2.6.
|
|
1521
|
+
var version = "2.6.3";
|
|
1487
1522
|
|
|
1488
1523
|
// src/index.ts
|
|
1489
1524
|
globalThis.FormData ??= import_undici2.FormData;
|