gamerbot-module 1.2.2 → 1.2.3
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/classes/gamerbot.js
CHANGED
|
@@ -11,27 +11,40 @@ export class GamerBotAPI {
|
|
|
11
11
|
if (dev) {
|
|
12
12
|
GamerBotAPI.API_URL = "http://localhost:3000";
|
|
13
13
|
}
|
|
14
|
-
this.getAPIStatus().then(() => {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
this.getAPIStatus().then((t) => {
|
|
15
|
+
if (t) {
|
|
16
|
+
console.log("API is available");
|
|
17
|
+
}
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
async getAPIStatus() {
|
|
20
|
-
const response = await fetch(GamerBotAPI.API_URL);
|
|
21
|
+
const response = await fetch(GamerBotAPI.API_URL).catch(() => { });
|
|
22
|
+
if (response == undefined) {
|
|
23
|
+
return await new Promise(r => {
|
|
24
|
+
console.error("API is not available, trying to connect to the API again in 5 seconds");
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
this.getAPIStatus();
|
|
27
|
+
r(false);
|
|
28
|
+
}, 5000);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
21
31
|
const data = await response.json().catch(() => {
|
|
22
32
|
console.error("API is not available, trying to connect to the API again in 5 seconds");
|
|
23
33
|
setTimeout(() => {
|
|
24
34
|
this.getAPIStatus();
|
|
25
35
|
}, 5000);
|
|
26
36
|
});
|
|
27
|
-
if (data.service == "OK")
|
|
28
|
-
|
|
37
|
+
if (data.service == "OK") {
|
|
38
|
+
this.apiStatus = true;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
29
41
|
else {
|
|
30
42
|
console.error("API is not available, trying to connect to the API again in 5 seconds");
|
|
31
43
|
setTimeout(() => {
|
|
32
44
|
this.getAPIStatus();
|
|
33
45
|
}, 5000);
|
|
34
46
|
}
|
|
47
|
+
return false;
|
|
35
48
|
}
|
|
36
49
|
static arraysEqual(a, b) {
|
|
37
50
|
if (a === b)
|