char-slop/city-role-bot

discord auto role applicator bot for charlotte polycule city

git clone https://git.t4t.associates/char-slop/city-role-bot

Charlotte Somadd starboarda4093f0

main
1.8 KiB33 linesraw
1diff --git a/dist/lib/rest/RequestHandler.js b/dist/lib/rest/RequestHandler.js
2index 7bc68f1aa1878a545f150e78eac7b43155432824..b7d793c6827d704f8d67c070ecae224d61c3a330 100644
3--- a/dist/lib/rest/RequestHandler.js
4+++ b/dist/lib/rest/RequestHandler.js
5@@ -107,6 +107,7 @@ class RequestHandler {
6         return new Promise((resolve, reject) => {
7             async function attempt(cb) {
8                 const headers = options.headers ?? {};
9+                let timeout;
10                 try {
11                     if (typeof options.auth === "string") {
12                         headers.Authorization = options.auth;
13@@ -156,7 +157,6 @@ class RequestHandler {
14                     const url = `${this.options.baseURL}${options.path}${options.query && Array.from(options.query.keys()).length !== 0 ? `?${options.query.toString()}` : ""}`;
15                     let latency = Date.now();
16                     const controller = new AbortController();
17-                    let timeout;
18                     if (this.options.requestTimeout > 0 && this.options.requestTimeout !== Infinity) {
19                         timeout = setTimeout(() => controller.abort(), this.options.requestTimeout);
20                     }
21@@ -300,10 +300,9 @@ class RequestHandler {
22                     resolve(resBody);
23                 }
24                 catch (err) {
25+                    if (timeout) clearTimeout(timeout);
26                     cb();
27-                    if (err instanceof Error && err.constructor.name === "DOMException" && err.name === "AbortError") {
28-                        reject(new Error(`Request Timed Out (>${this.options.requestTimeout}ms) on ${options.method} ${options.path}`));
29-                    }
30+                    reject(err);
31                     this._manager.client.emit("error", err);
32                 }
33             }