Brozy123 commited on
Commit
a5ff332
·
verified ·
1 Parent(s): cf478c6

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +9 -3
index.js CHANGED
@@ -31,7 +31,7 @@ const client = new Client({
31
  ],
32
  partials: [Partials.Message, Partials.Channel, Partials.Reaction],
33
  rest: {
34
- api: 'https://canary.discord.com/api',
35
  version: '10',
36
  timeout: 60000
37
  },
@@ -1383,16 +1383,22 @@ async function initialize() {
1383
  }
1384
 
1385
  try {
1386
- console.log(`[*] Attempting connection to Discord (Attempt ${retryCount + 1})...`);
1387
  await client.login(TOKEN);
1388
  } catch (err) {
1389
  console.error(`[ERROR] Authentication Failed: ${err.message}`);
1390
 
 
 
 
 
 
 
1391
  // Exponential backoff for retries
1392
  retryCount++;
1393
  const delay = Math.min(1000 * Math.pow(2, retryCount), maxRetryDelay);
1394
 
1395
- console.log(`[*] Retrying in ${delay / 1000}s...`);
1396
  setTimeout(login, delay);
1397
  }
1398
  }
 
31
  ],
32
  partials: [Partials.Message, Partials.Channel, Partials.Reaction],
33
  rest: {
34
+ api: `https://${networkFix.getTargetDomain()}/api`,
35
  version: '10',
36
  timeout: 60000
37
  },
 
1383
  }
1384
 
1385
  try {
1386
+ console.log(`[*] Attempting connection to Discord (Attempt ${retryCount + 1}) on ${networkFix.getTargetDomain()}...`);
1387
  await client.login(TOKEN);
1388
  } catch (err) {
1389
  console.error(`[ERROR] Authentication Failed: ${err.message}`);
1390
 
1391
+ // Professional Failover: Rotate endpoint and try again
1392
+ networkFix.rotateEndpoint();
1393
+ if (client.rest) {
1394
+ client.rest.options.api = `https://${networkFix.getTargetDomain()}/api`;
1395
+ }
1396
+
1397
  // Exponential backoff for retries
1398
  retryCount++;
1399
  const delay = Math.min(1000 * Math.pow(2, retryCount), maxRetryDelay);
1400
 
1401
+ console.log(`[*] Retrying in ${delay / 1000}s with new route...`);
1402
  setTimeout(login, delay);
1403
  }
1404
  }