mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 00:10:58 -05:00
You're a failure!
This commit is contained in:
parent
07b4b0c793
commit
8fc5c1a8db
@ -149,12 +149,11 @@ export async function requestServerData(client:TClient, server:IServerExt):Promi
|
|||||||
} else if (data.status === 404) Logger.console('log', loggingPrefix, `(${i+1}/${maxRetries}) ${server.serverName} responded with an error (404), API is disabled or mismatched code`);
|
} else if (data.status === 404) Logger.console('log', loggingPrefix, `(${i+1}/${maxRetries}) ${server.serverName} responded with an error (404), API is disabled or mismatched code`);
|
||||||
else if (data.status === 400) Logger.console('log', loggingPrefix, `(${i+1}/${maxRetries}) ${server.serverName} responded with an error (400), bad endpoint or ratelimited`); // Seems to be taking L's left and right hourly...
|
else if (data.status === 400) Logger.console('log', loggingPrefix, `(${i+1}/${maxRetries}) ${server.serverName} responded with an error (400), bad endpoint or ratelimited`); // Seems to be taking L's left and right hourly...
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
if (typeof server.failureCount !== 'number') server.failureCount = 0;
|
||||||
|
|
||||||
Logger.console('log', loggingPrefix, `Couldn't get data for ${server.serverName}: ${err.message}`);
|
Logger.console('log', loggingPrefix, `Couldn't get data for ${server.serverName}: ${err.message}`);
|
||||||
server.failureCount++;
|
server.failureCount++;
|
||||||
if (server.failureCount >= 6 && server.isActive) {
|
if (server.failureCount >= 4 && server.isActive) silenceServer(client, server);
|
||||||
Logger.console('log', loggingPrefix, `Maximum failed requests (${server.failureCount}) reached for ${server.serverName}, silenced server for 10 minutes`);
|
|
||||||
silenceServer(client, server, 600000);
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
await new Promise(resolve=>setTimeout(resolve, delay));
|
await new Promise(resolve=>setTimeout(resolve, delay));
|
||||||
@ -208,8 +207,9 @@ function convertPlayerUptime(playTime:number) {
|
|||||||
return (Days > 0 ? Days+' d ':'')+(Hours > 0 ? Hours+' h ':'')+(Minutes > 0 ? Minutes+' m':'')
|
return (Days > 0 ? Days+' d ':'')+(Hours > 0 ? Hours+' h ':'')+(Minutes > 0 ? Minutes+' m':'')
|
||||||
}
|
}
|
||||||
|
|
||||||
function silenceServer(client:TClient, server:IServerExt, time:number):void {
|
function silenceServer(client:TClient, server:IServerExt):void {
|
||||||
|
Logger.console('log', loggingPrefix, `Maximum failed requests (${server.failureCount}) reached for ${server.serverName}, silenced server for 20 minutes`);
|
||||||
client.MPServer.toggleServerUsability(server.serverName, false);
|
client.MPServer.toggleServerUsability(server.serverName, false);
|
||||||
setTimeout(()=>client.MPServer.toggleServerUsability(server.serverName, true), time)
|
setTimeout(()=>client.MPServer.toggleServerUsability(server.serverName, true), 1200000);
|
||||||
server.failureCount = 0;
|
server.failureCount = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user