Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -1522,15 +1522,19 @@ async function initialize() {
|
|
| 1522 |
return;
|
| 1523 |
} else if (testRes) {
|
| 1524 |
console.log(`[SUCCESS] ✅ Connected via ${currentApi}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1525 |
} else {
|
| 1526 |
const errDetail = testError ? `${testError.status || 'TIMEOUT'} - ${testError.message}` : "Unknown Error";
|
| 1527 |
console.warn(`[BLOCKED] ⚠️ ${currentApi} failed: ${errDetail}`);
|
| 1528 |
|
| 1529 |
-
// If we have a Proxy worker set, don't rotate to known-blocked endpoints
|
| 1530 |
if (process.env.DISCORD_BASE_URL && currentEndpointIndex === 0) {
|
| 1531 |
console.log("[!] Still blocked via Worker. Retrying worker path in 5s...");
|
| 1532 |
await new Promise(r => setTimeout(r, 5000));
|
| 1533 |
-
|
|
|
|
| 1534 |
}
|
| 1535 |
|
| 1536 |
currentEndpointIndex = (currentEndpointIndex + 1) % DISCORD_ENDPOINTS.length;
|
|
|
|
| 1522 |
return;
|
| 1523 |
} else if (testRes) {
|
| 1524 |
console.log(`[SUCCESS] ✅ Connected via ${currentApi}`);
|
| 1525 |
+
// Lock the bot to the tunnel
|
| 1526 |
+
client.token = TOKEN;
|
| 1527 |
+
client.options.rest.api = currentApi;
|
| 1528 |
+
if (client.rest) client.rest.options.api = currentApi;
|
| 1529 |
} else {
|
| 1530 |
const errDetail = testError ? `${testError.status || 'TIMEOUT'} - ${testError.message}` : "Unknown Error";
|
| 1531 |
console.warn(`[BLOCKED] ⚠️ ${currentApi} failed: ${errDetail}`);
|
| 1532 |
|
|
|
|
| 1533 |
if (process.env.DISCORD_BASE_URL && currentEndpointIndex === 0) {
|
| 1534 |
console.log("[!] Still blocked via Worker. Retrying worker path in 5s...");
|
| 1535 |
await new Promise(r => setTimeout(r, 5000));
|
| 1536 |
+
login();
|
| 1537 |
+
return;
|
| 1538 |
}
|
| 1539 |
|
| 1540 |
currentEndpointIndex = (currentEndpointIndex + 1) % DISCORD_ENDPOINTS.length;
|