Spaces:
Runtime error
Runtime error
Update index.js
Browse files
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();
|