Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -125,16 +125,14 @@ client.once('ready', async () => {
|
|
| 125 |
|
| 126 |
|
| 127 |
try {
|
| 128 |
-
|
| 129 |
-
await client.application.commands.set([]);
|
| 130 |
|
| 131 |
-
//
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
console.log('[*] Guild-specific Slash commands registered successfully.');
|
| 136 |
} catch (e) {
|
| 137 |
-
console.error(`[
|
| 138 |
}
|
| 139 |
|
| 140 |
// Auto-Friendly Background Loop
|
|
@@ -1401,17 +1399,18 @@ client.on('error', (e) => {
|
|
| 1401 |
|
| 1402 |
console.log("[*] Attempting Discord login...");
|
| 1403 |
|
| 1404 |
-
// Watchdog: If not logged in within
|
| 1405 |
let loginWatchdog = setTimeout(() => {
|
| 1406 |
if (!client.isReady()) {
|
| 1407 |
console.log(`[!] Login Watchdog: Connection hanging on ${networkFix.getTargetDomain()}. Rotating and restarting...`);
|
| 1408 |
networkFix.rotateEndpoint();
|
| 1409 |
process.exit(1);
|
| 1410 |
}
|
| 1411 |
-
},
|
| 1412 |
|
| 1413 |
async function performLogin() {
|
| 1414 |
try {
|
|
|
|
| 1415 |
await client.login(TOKEN);
|
| 1416 |
clearTimeout(loginWatchdog);
|
| 1417 |
console.log("[*] client.login() successful.");
|
|
@@ -1421,9 +1420,6 @@ async function performLogin() {
|
|
| 1421 |
|
| 1422 |
networkFix.rotateEndpoint();
|
| 1423 |
|
| 1424 |
-
// Update client rest options with new domain if needed
|
| 1425 |
-
// (Though network_fix.js handles this globally now)
|
| 1426 |
-
|
| 1427 |
// Reset watchdog
|
| 1428 |
clearTimeout(loginWatchdog);
|
| 1429 |
loginWatchdog = setTimeout(() => {
|
|
@@ -1431,7 +1427,7 @@ async function performLogin() {
|
|
| 1431 |
console.log(`[!] Login Watchdog: Connection hanging. Restarting...`);
|
| 1432 |
process.exit(1);
|
| 1433 |
}
|
| 1434 |
-
},
|
| 1435 |
|
| 1436 |
setTimeout(performLogin, 10000);
|
| 1437 |
}
|
|
|
|
| 125 |
|
| 126 |
|
| 127 |
try {
|
| 128 |
+
console.log(`[*] Registering global commands for ${client.guilds.cache.size} servers...`);
|
|
|
|
| 129 |
|
| 130 |
+
// Register globally (this is fast and avoids per-guild rate limits)
|
| 131 |
+
await client.application.commands.set(commandsData);
|
| 132 |
+
|
| 133 |
+
console.log('[*] Global Slash commands registered successfully.');
|
|
|
|
| 134 |
} catch (e) {
|
| 135 |
+
console.error(`[!] Register Error: ${e}`);
|
| 136 |
}
|
| 137 |
|
| 138 |
// Auto-Friendly Background Loop
|
|
|
|
| 1399 |
|
| 1400 |
console.log("[*] Attempting Discord login...");
|
| 1401 |
|
| 1402 |
+
// Watchdog: If not logged in within 3 minutes, rotate and restart
|
| 1403 |
let loginWatchdog = setTimeout(() => {
|
| 1404 |
if (!client.isReady()) {
|
| 1405 |
console.log(`[!] Login Watchdog: Connection hanging on ${networkFix.getTargetDomain()}. Rotating and restarting...`);
|
| 1406 |
networkFix.rotateEndpoint();
|
| 1407 |
process.exit(1);
|
| 1408 |
}
|
| 1409 |
+
}, 180000); // 3 minutes
|
| 1410 |
|
| 1411 |
async function performLogin() {
|
| 1412 |
try {
|
| 1413 |
+
console.log(`[*] Initiating login on endpoint: ${networkFix.getTargetDomain()}...`);
|
| 1414 |
await client.login(TOKEN);
|
| 1415 |
clearTimeout(loginWatchdog);
|
| 1416 |
console.log("[*] client.login() successful.");
|
|
|
|
| 1420 |
|
| 1421 |
networkFix.rotateEndpoint();
|
| 1422 |
|
|
|
|
|
|
|
|
|
|
| 1423 |
// Reset watchdog
|
| 1424 |
clearTimeout(loginWatchdog);
|
| 1425 |
loginWatchdog = setTimeout(() => {
|
|
|
|
| 1427 |
console.log(`[!] Login Watchdog: Connection hanging. Restarting...`);
|
| 1428 |
process.exit(1);
|
| 1429 |
}
|
| 1430 |
+
}, 180000); // 3 minutes
|
| 1431 |
|
| 1432 |
setTimeout(performLogin, 10000);
|
| 1433 |
}
|