From 3151ad980883a1969500a93a4f4504ac19e4c9a8 Mon Sep 17 00:00:00 2001 From: Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> Date: Sat, 2 Apr 2022 11:11:17 +0800 Subject: Make more features work when my server is down --- featureClass/featureManager.js | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'featureClass') diff --git a/featureClass/featureManager.js b/featureClass/featureManager.js index 934feca..8b5a023 100644 --- a/featureClass/featureManager.js +++ b/featureClass/featureManager.js @@ -71,28 +71,25 @@ class FeatureManager { this.featureSettingsData = {} - new Thread(()=>{ - - try{ - if(fetch("http://soopymc.my.to/api/soopyv2/ping").responseCode() >= 400){ - ChatLib.chat(this.messagePrefix + "&cError: Could not connect to Soopy's server. This may cause issues with features breaking but will (hopefully) be back soon.") - } - }catch(e){ + let fetchD = fetch("http://soopymc.my.to/api/soopyv2/ping").async(d=>{ + if(fetchD.responseCode() >= 400 || fetchD.responseCode() === -1){ ChatLib.chat(this.messagePrefix + "&cError: Could not connect to Soopy's server. This may cause issues with features breaking but will (hopefully) be back soon.") } - - this.loadFeatureMetas() - - this.loadFeatureSettings() - Object.keys(this.featureMetas).forEach((feature)=>{ - if(this.featureSettingsData[feature] && this.featureSettingsData[feature].enabled){ - this.loadFeature(feature) - } - }) - - this.finishedLoading = true - }).start() + new Thread(()=>{ + this.loadFeatureMetas() + + this.loadFeatureSettings() + + Object.keys(this.featureMetas).forEach((feature)=>{ + if(this.featureSettingsData[feature] && this.featureSettingsData[feature].enabled){ + this.loadFeature(feature) + } + }) + + this.finishedLoading = true + }).start() + }, true) this.registerStep(false, 30, ()=>{ if(this.featureSettingsDataLastUpdated){ -- cgit