aboutsummaryrefslogtreecommitdiff
path: root/refresh/pluralkit.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-05-27 16:01:58 +0200
committerMinteck <contact@minteck.org>2022-05-27 16:01:58 +0200
commitff55cb779941ce6ea178b3ea37f1e519f47d7937 (patch)
tree2186fa5b422d073650616a4361eb3b9c6d205525 /refresh/pluralkit.js
parent7d1c7859cdbdbd2407426ac6c72e501bab1dd47b (diff)
downloadvaportrail-ff55cb779941ce6ea178b3ea37f1e519f47d7937.tar.gz
vaportrail-ff55cb779941ce6ea178b3ea37f1e519f47d7937.tar.bz2
vaportrail-ff55cb779941ce6ea178b3ea37f1e519f47d7937.zip
Rewrite /servers
Diffstat (limited to 'refresh/pluralkit.js')
-rw-r--r--refresh/pluralkit.js136
1 files changed, 70 insertions, 66 deletions
diff --git a/refresh/pluralkit.js b/refresh/pluralkit.js
index 9f248d5..9539676 100644
--- a/refresh/pluralkit.js
+++ b/refresh/pluralkit.js
@@ -46,79 +46,83 @@ module.exports = () => {
}
setTimeout(() => {
- superagent.get(`https://api.pluralkit.me/v2/systems/${system}`)
- .timeout({
- response: 5000,
- })
- .then(data => data = data.body)
- .then(data => {
- status.general = data;
- superagent.get(`https://api.pluralkit.me/v2/systems/${system}/members`)
- .timeout({
- response: 5000,
- })
- .then(data => data = data.body)
- .then(data => {
- status.members = data;
- setTimeout(() => {
- superagent.get(`https://api.pluralkit.me/v2/systems/${system}/fronters`)
- .timeout({
- response: 5000,
- })
- .then(data => data = data.body)
- .then(data => {
- status.fronters = data;
- })
- .catch(reason => {
- if (reason.timeout) {
- // We timed out.
+ setTimeout(() => {
+ superagent.get(`https://api.pluralkit.me/v2/systems/${system}`)
+ .timeout({
+ response: 5000,
+ })
+ .then(data => data = data.body)
+ .then(data => {
+ status.general = data;
+ setTimeout(() => {
+ superagent.get(`https://api.pluralkit.me/v2/systems/${system}/members`)
+ .timeout({
+ response: 5000,
+ })
+ .then(data => data = data.body)
+ .then(data => {
+ status.members = data;
+ setTimeout(() => {
+ superagent.get(`https://api.pluralkit.me/v2/systems/${system}/fronters`)
+ .timeout({
+ response: 5000,
+ })
+ .then(data => data = data.body)
+ .then(data => {
+ status.fronters = data;
+ })
+ .catch(reason => {
+ if (reason.timeout) {
+ // We timed out.
+ status.available = false;
+ } else {
+ if (reason.code === "ECONNREFUSED") {
+ status.available = false;
+ console.warn("Error querying PluralKit API.")
+ } else {
+ console.error(reason);
+ }
+ }
+ })
+ .finally(() => {
+ stats[system] = status;
+
+ if (Object.keys(stats).length === systems.length) {
+ res(stats);
+ }
+ });
+ }, 1000)
+ })
+ .catch(reason => {
+ if (reason.timeout) {
+ // We timed out.
+ status.available = false;
+ } else {
+ if (reason.code === "ECONNREFUSED") {
status.available = false;
+ console.warn("Error querying PluralKit API.")
} else {
- if(reason.code === "ECONNREFUSED") {
- status.available = false;
- console.warn("Error querying PluralKit API.")
- } else {
- console.error(reason);
- }
- }
- })
- .finally(() => {
- stats[system] = status;
-
- if(Object.keys(stats).length === systems.length) {
- res(stats);
+ console.error(reason);
}
- });
- }, 1000)
- })
- .catch(reason => {
- if (reason.timeout) {
- // We timed out.
+ }
+ })
+ }, 1000);
+ })
+ .catch(reason => {
+ if (reason.timeout) {
+ // We timed out.
+ status.available = false;
+ } else {
+ if (reason.code === "ECONNREFUSED") {
status.available = false;
+ console.warn("Error querying PluralKit API.")
} else {
- if(reason.code === "ECONNREFUSED") {
- status.available = false;
- console.warn("Error querying PluralKit API.")
- } else {
- console.error(reason);
- }
+ console.error(reason);
}
- })
- })
- .catch(reason => {
- if (reason.timeout) {
- // We timed out.
- status.available = false;
- } else {
- if(reason.code === "ECONNREFUSED") {
- status.available = false;
- console.warn("Error querying PluralKit API.")
- } else {
- console.error(reason);
}
- }
- })
- }, 1000)
+ })
+ }, 1000);
+ }, 1000);
}
});
}