Brozy123 commited on
Commit
3eb61cb
·
verified ·
1 Parent(s): e5561dc

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +10 -2
index.js CHANGED
@@ -1385,7 +1385,13 @@ setInterval(async () => {
1385
 
1386
  // Attempt to keep session alive or force a new login if really dead
1387
  if (client.ws.status === 7 || client.ws.status === 9) { // DISCONNECTED or INVALID_SESSION
1388
- process.exit(1); // Force a full container restart by PM2/HuggingFace
 
 
 
 
 
 
1389
  }
1390
  }
1391
  }
@@ -1448,7 +1454,9 @@ async function initialize() {
1448
  async function login() {
1449
  if (!TOKEN || TOKEN.length < 10) {
1450
  console.error("[CRITICAL] Discord Token is missing or malformed.");
1451
- process.exit(1);
 
 
1452
  }
1453
 
1454
  try {
 
1385
 
1386
  // Attempt to keep session alive or force a new login if really dead
1387
  if (client.ws.status === 7 || client.ws.status === 9) { // DISCONNECTED or INVALID_SESSION
1388
+ console.log("[*] Invalid/disconnected session detected, attempting soft relogin...");
1389
+ client.destroy();
1390
+ setTimeout(() => {
1391
+ client.login(TOKEN).catch((e) => {
1392
+ console.error('[ERROR] Soft relogin failed:', e.message || e);
1393
+ });
1394
+ }, 2000);
1395
  }
1396
  }
1397
  }
 
1454
  async function login() {
1455
  if (!TOKEN || TOKEN.length < 10) {
1456
  console.error("[CRITICAL] Discord Token is missing or malformed.");
1457
+ console.log("[*] Will retry token/login check in 30s...");
1458
+ setTimeout(login, 30000);
1459
+ return;
1460
  }
1461
 
1462
  try {