@discordeno/rest 19.0.0-next.7b5d99e → 19.0.0-next.7c031df
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/manager.d.ts.map +1 -1
- package/dist/manager.js +7 -4
- package/dist/manager.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
package/dist/manager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AAiEA,OAAO,KAAK,EAA4B,wBAAwB,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAA;AAKrH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AAiEA,OAAO,KAAK,EAA4B,wBAAwB,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAA;AAKrH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,CAgqDhF"}
|
package/dist/manager.js
CHANGED
|
@@ -6,11 +6,13 @@ import { Queue } from './queue.js';
|
|
|
6
6
|
// TODO: make dynamic based on package.json file
|
|
7
7
|
const version = '19.0.0-alpha.1';
|
|
8
8
|
export function createRestManager(options) {
|
|
9
|
-
|
|
10
|
-
if (!
|
|
9
|
+
const applicationId = options.applicationId ? BigInt(options.applicationId) : options.token ? getBotIdFromToken(options.token) : undefined;
|
|
10
|
+
if (!applicationId) {
|
|
11
|
+
throw new Error('`applicationId` was not provided and was not able to extract the id from the bots token. Please explicitly pass `applicationId` to the rest manager.');
|
|
12
|
+
}
|
|
11
13
|
const rest = {
|
|
12
14
|
token: options.token,
|
|
13
|
-
applicationId
|
|
15
|
+
applicationId,
|
|
14
16
|
version: options.version ?? 10,
|
|
15
17
|
baseUrl: options.proxy?.baseUrl ?? 'https://discord.com/api',
|
|
16
18
|
maxRetryCount: Infinity,
|
|
@@ -549,7 +551,7 @@ export function createRestManager(options) {
|
|
|
549
551
|
const headers = {
|
|
550
552
|
'user-agent': `DiscordBot (https://github.com/discordeno/discordeno, v${version})`
|
|
551
553
|
};
|
|
552
|
-
if (
|
|
554
|
+
if (options?.unauthorized !== false) headers.authorization = `Bot ${rest.token}`;
|
|
553
555
|
// IF A REASON IS PROVIDED ENCODE IT IN HEADERS
|
|
554
556
|
if (options?.reason !== undefined) {
|
|
555
557
|
headers['x-audit-log-reason'] = encodeURIComponent(options?.reason);
|
|
@@ -794,6 +796,7 @@ export function createRestManager(options) {
|
|
|
794
796
|
}
|
|
795
797
|
return result.status !== 204 ? await result.json() : undefined;
|
|
796
798
|
}
|
|
799
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
797
800
|
return await new Promise(async (resolve, reject)=>{
|
|
798
801
|
const payload = {
|
|
799
802
|
url,
|