discordeno 16.0.0 → 16.0.1

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.
@@ -53,6 +53,9 @@ export async function processGlobalQueue(rest) {
53
53
  bucketId: request.payload.bucketId,
54
54
  reject: request.request.reject,
55
55
  respond: request.request.respond,
56
+ retryRequest: function () {
57
+ rest.globalQueue.unshift(request);
58
+ },
56
59
  retryCount: request.payload.retryCount ?? 0,
57
60
  payload: rest.createRequestBody(rest, {
58
61
  method: request.request.method,
@@ -1,4 +1,5 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
+ import { delay } from "../mod.js";
2
3
  import { HTTPResponseCodes } from "../types/shared.js";
3
4
  import { BASE_URL } from "../util/constants.js";
4
5
  export async function sendRequest(rest, options) {
@@ -62,6 +63,7 @@ export async function sendRequest(rest, options) {
62
63
  });
63
64
  }
64
65
  else {
66
+ // TOO MANY ATTEMPTS, GET RID OF REQUEST FROM QUEUE.
65
67
  if (options.retryCount && options.retryCount++ >= rest.maxRetryCount) {
66
68
  rest.debug(`[REST - RetriesMaxed] ${JSON.stringify(options)}`);
67
69
  // REMOVE ITEM FROM QUEUE TO PREVENT RETRY
@@ -72,6 +74,11 @@ export async function sendRequest(rest, options) {
72
74
  });
73
75
  // @ts-ignore Code should never reach here
74
76
  return;
77
+ } // RATE LIMITED, ADD BACK TO QUEUE
78
+ else {
79
+ const json = await response.json();
80
+ await delay(json.retry_after * 1000);
81
+ return options.retryRequest?.();
75
82
  }
76
83
  }
77
84
  }
@@ -4,7 +4,7 @@ export const BASE_URL = "https://discord.com/api";
4
4
  export const API_VERSION = 10;
5
5
  // TODO: update this version
6
6
  /** https://github.com/discordeno/discordeno/releases */
7
- export const DISCORDENO_VERSION = "16.0.0";
7
+ export const DISCORDENO_VERSION = "16.0.1";
8
8
  /** https://discord.com/developers/docs/reference#user-agent */
9
9
  export const USER_AGENT = `DiscordBot (https://github.com/discordeno/discordeno, v${DISCORDENO_VERSION})`;
10
10
  /** https://discord.com/developers/docs/reference#image-formatting-image-base-url */
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./script/mod.js",
4
4
  "types": "./types/mod.d.ts",
5
5
  "name": "discordeno",
6
- "version": "16.0.0",
6
+ "version": "16.0.1",
7
7
  "description": "Discordeno is simplistic, easy-to-use, versatile while being efficient and lightweight.",
8
8
  "keywords": [
9
9
  "javascript",
@@ -79,6 +79,9 @@ async function processGlobalQueue(rest) {
79
79
  bucketId: request.payload.bucketId,
80
80
  reject: request.request.reject,
81
81
  respond: request.request.respond,
82
+ retryRequest: function () {
83
+ rest.globalQueue.unshift(request);
84
+ },
82
85
  retryCount: request.payload.retryCount ?? 0,
83
86
  payload: rest.createRequestBody(rest, {
84
87
  method: request.request.method,
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.sendRequest = void 0;
27
27
  const dntShim = __importStar(require("../_dnt.shims.js"));
28
+ const mod_js_1 = require("../mod.js");
28
29
  const shared_js_1 = require("../types/shared.js");
29
30
  const constants_js_1 = require("../util/constants.js");
30
31
  async function sendRequest(rest, options) {
@@ -88,6 +89,7 @@ async function sendRequest(rest, options) {
88
89
  });
89
90
  }
90
91
  else {
92
+ // TOO MANY ATTEMPTS, GET RID OF REQUEST FROM QUEUE.
91
93
  if (options.retryCount && options.retryCount++ >= rest.maxRetryCount) {
92
94
  rest.debug(`[REST - RetriesMaxed] ${JSON.stringify(options)}`);
93
95
  // REMOVE ITEM FROM QUEUE TO PREVENT RETRY
@@ -98,6 +100,11 @@ async function sendRequest(rest, options) {
98
100
  });
99
101
  // @ts-ignore Code should never reach here
100
102
  return;
103
+ } // RATE LIMITED, ADD BACK TO QUEUE
104
+ else {
105
+ const json = await response.json();
106
+ await (0, mod_js_1.delay)(json.retry_after * 1000);
107
+ return options.retryRequest?.();
101
108
  }
102
109
  }
103
110
  }
@@ -7,7 +7,7 @@ exports.BASE_URL = "https://discord.com/api";
7
7
  exports.API_VERSION = 10;
8
8
  // TODO: update this version
9
9
  /** https://github.com/discordeno/discordeno/releases */
10
- exports.DISCORDENO_VERSION = "16.0.0";
10
+ exports.DISCORDENO_VERSION = "16.0.1";
11
11
  /** https://discord.com/developers/docs/reference#user-agent */
12
12
  exports.USER_AGENT = `DiscordBot (https://github.com/discordeno/discordeno, v${exports.DISCORDENO_VERSION})`;
13
13
  /** https://discord.com/developers/docs/reference#image-formatting-image-base-url */
@@ -7,6 +7,7 @@ export interface RestSendRequestOptions {
7
7
  bucketId?: string;
8
8
  reject?: Function;
9
9
  respond?: Function;
10
+ retryRequest?: Function;
10
11
  retryCount?: number;
11
12
  payload?: {
12
13
  headers: Record<string, string>;
@@ -52,6 +52,8 @@ export interface DiscordConnection {
52
52
  visibility: VisibilityTypes;
53
53
  /** An array of partial server integrations */
54
54
  integrations?: DiscordIntegration[];
55
+ /** Whether this connection has a corresponding third party OAuth2 token. */
56
+ two_way_link: boolean;
55
57
  }
56
58
  /** https://discord.com/developers/docs/resources/user#connection-object-services */
57
59
  export declare type DiscordConnectionServices = "battlenet" | "ebay" | "epicgames" | "facebook" | "github" | "leagueoflegends" | "playstation" | "reddit" | "riotgames" | "spotify" | "skype" | "steam" | "twitch" | "twitter" | "xbox" | "youtube";
@@ -3,7 +3,7 @@ export declare const BASE_URL = "https://discord.com/api";
3
3
  /** https://discord.com/developers/docs/reference#api-versioning-api-versions */
4
4
  export declare const API_VERSION = 10;
5
5
  /** https://github.com/discordeno/discordeno/releases */
6
- export declare const DISCORDENO_VERSION = "16.0.0";
6
+ export declare const DISCORDENO_VERSION = "16.0.1";
7
7
  /** https://discord.com/developers/docs/reference#user-agent */
8
8
  export declare const USER_AGENT: string;
9
9
  /** https://discord.com/developers/docs/reference#image-formatting-image-base-url */