Brozy123 commited on
Commit
fd471bb
·
verified ·
1 Parent(s): 4004a27

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +12 -0
index.js CHANGED
@@ -1394,9 +1394,21 @@ client.on('error', (e) => {
1394
  });
1395
 
1396
  console.log("[*] Attempting Discord login...");
 
 
 
 
 
 
 
 
 
 
1397
  client.login(TOKEN).then(() => {
 
1398
  console.log("[*] client.login() promise resolved.");
1399
  }).catch(e => {
 
1400
  console.error(`[!] Login Failed:`, e);
1401
  console.log("[*] Retrying login with rotated endpoint...");
1402
  networkFix.rotateEndpoint();
 
1394
  });
1395
 
1396
  console.log("[*] Attempting Discord login...");
1397
+
1398
+ // Watchdog: If not logged in within 45 seconds, rotate and restart
1399
+ const loginWatchdog = setTimeout(() => {
1400
+ if (!client.isReady()) {
1401
+ console.log("[!] Login Watchdog: Connection hanging. Rotating endpoint and restarting...");
1402
+ networkFix.rotateEndpoint();
1403
+ process.exit(1);
1404
+ }
1405
+ }, 45000);
1406
+
1407
  client.login(TOKEN).then(() => {
1408
+ clearTimeout(loginWatchdog);
1409
  console.log("[*] client.login() promise resolved.");
1410
  }).catch(e => {
1411
+ clearTimeout(loginWatchdog);
1412
  console.error(`[!] Login Failed:`, e);
1413
  console.log("[*] Retrying login with rotated endpoint...");
1414
  networkFix.rotateEndpoint();