@discordjs/rest 3.0.0-dev.1756252917-50018979e → 3.0.0-dev.1756468900-cde757b7c

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/index.mjs CHANGED
@@ -98,7 +98,7 @@ import { CDNRoutes } from "discord-api-types/v10";
98
98
  // src/lib/utils/constants.ts
99
99
  import { getUserAgentAppendix } from "@discordjs/util";
100
100
  import { APIVersion } from "discord-api-types/v10";
101
- var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-dev.1756252917-50018979e)`;
101
+ var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-dev.1756468900-cde757b7c)`;
102
102
  var DefaultUserAgentAppendix = getUserAgentAppendix();
103
103
  var DefaultRestOptions = {
104
104
  agent: null,
@@ -642,6 +642,7 @@ function normalizeRateLimitOffset(offset, route) {
642
642
  __name(normalizeRateLimitOffset, "normalizeRateLimitOffset");
643
643
 
644
644
  // src/lib/handlers/Shared.ts
645
+ var authFalseWarningEmitted = false;
645
646
  var invalidCount = 0;
646
647
  var invalidCountResetTime = null;
647
648
  function incrementInvalidCount(manager) {
@@ -704,11 +705,21 @@ async function handleErrors(manager, res, method, url, requestData, retries) {
704
705
  throw new HTTPError(status, res.statusText, method, url, requestData);
705
706
  } else {
706
707
  if (status >= 400 && status < 500) {
708
+ const data = await parseResponse(res);
709
+ const isDiscordError = "code" in data;
707
710
  if (status === 401 && requestData.auth === true) {
711
+ if (isDiscordError && data.code !== 0 && !authFalseWarningEmitted) {
712
+ const errorText = `Encountered HTTP 401 with error ${data.code}: ${data.message}. Your token will be removed from this REST instance. If you are using @discordjs/rest directly, consider adding 'auth: false' to the request. Open an issue with your library if not.`;
713
+ if (typeof globalThis.process !== "undefined" && typeof globalThis.process.emitWarning === "function") {
714
+ globalThis.process.emitWarning(errorText);
715
+ } else {
716
+ console.warn(errorText);
717
+ }
718
+ authFalseWarningEmitted = true;
719
+ }
708
720
  manager.setToken(null);
709
721
  }
710
- const data = await parseResponse(res);
711
- throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
722
+ throw new DiscordAPIError(data, isDiscordError ? data.code : data.error, status, method, url, requestData);
712
723
  }
713
724
  return res;
714
725
  }
@@ -1443,7 +1454,7 @@ var REST = class _REST extends AsyncEventEmitter {
1443
1454
  };
1444
1455
 
1445
1456
  // src/shared.ts
1446
- var version = "3.0.0-dev.1756252917-50018979e";
1457
+ var version = "3.0.0-dev.1756468900-cde757b7c";
1447
1458
 
1448
1459
  // src/index.ts
1449
1460
  setDefaultStrategy(shouldUseGlobalFetchAndWebSocket() ? fetch : makeRequest);