@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.
@@ -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,CA2pDhF"}
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
- // Falsy token string check
10
- if (!options.token) throw new Error('You must provide a valid token.');
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: options.applicationId ? BigInt(options.applicationId) : getBotIdFromToken(options.token),
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 (!options?.unauthorized) headers.authorization = `Bot ${rest.token}`;
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,