Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -52,14 +52,13 @@ const client = new Client({
|
|
| 52 |
rest: {
|
| 53 |
timeout: 120_000,
|
| 54 |
agent: ultimateFix.dispatcher,
|
|
|
|
| 55 |
},
|
| 56 |
ws: {
|
| 57 |
agent: require('https').globalAgent
|
| 58 |
}
|
| 59 |
});
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
// Increased to 90s for slow HF cold-starts
|
| 64 |
let connectionTimeout = setTimeout(() => {
|
| 65 |
if (!client.isReady()) {
|
|
@@ -278,17 +277,12 @@ async function logTransaction(client, commandName, user, guild, member) {
|
|
| 278 |
|
| 279 |
// Message Command Handler (Prefix Support)
|
| 280 |
client.on('messageCreate', async (message) => {
|
| 281 |
-
if (message.author.bot) return;
|
| 282 |
-
|
| 283 |
const prefix = storage.getPrefix(message.guildId);
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
if (!message.content.startsWith(prefix)) return;
|
| 287 |
|
| 288 |
const args = message.content.slice(prefix.length).trim().split(/ +/);
|
| 289 |
const commandName = args.shift().toLowerCase();
|
| 290 |
|
| 291 |
-
|
| 292 |
const allCommands = [...commandsData.map(c => c.name), 'sync', 'sync_cmds', 'reboot', 'grantservers', 'servers', 'help', 'motm', 'profileimage'];
|
| 293 |
if (allCommands.includes(commandName)) {
|
| 294 |
logTransaction(client, commandName, message.author, message.guild, message.member);
|
|
@@ -1478,8 +1472,21 @@ async function initialize() {
|
|
| 1478 |
|
| 1479 |
retryCount++;
|
| 1480 |
try {
|
| 1481 |
-
console.log(`[*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1482 |
|
|
|
|
| 1483 |
|
| 1484 |
|
| 1485 |
// Destroy any stale connection before retrying
|
|
|
|
| 52 |
rest: {
|
| 53 |
timeout: 120_000,
|
| 54 |
agent: ultimateFix.dispatcher,
|
| 55 |
+
api: 'https://canary.discord.com/api', // Use canary endpoint to bypass blocks
|
| 56 |
},
|
| 57 |
ws: {
|
| 58 |
agent: require('https').globalAgent
|
| 59 |
}
|
| 60 |
});
|
| 61 |
|
|
|
|
|
|
|
| 62 |
// Increased to 90s for slow HF cold-starts
|
| 63 |
let connectionTimeout = setTimeout(() => {
|
| 64 |
if (!client.isReady()) {
|
|
|
|
| 277 |
|
| 278 |
// Message Command Handler (Prefix Support)
|
| 279 |
client.on('messageCreate', async (message) => {
|
|
|
|
|
|
|
| 280 |
const prefix = storage.getPrefix(message.guildId);
|
| 281 |
+
if (message.author.bot || !message.content.startsWith(prefix)) return;
|
|
|
|
|
|
|
| 282 |
|
| 283 |
const args = message.content.slice(prefix.length).trim().split(/ +/);
|
| 284 |
const commandName = args.shift().toLowerCase();
|
| 285 |
|
|
|
|
| 286 |
const allCommands = [...commandsData.map(c => c.name), 'sync', 'sync_cmds', 'reboot', 'grantservers', 'servers', 'help', 'motm', 'profileimage'];
|
| 287 |
if (allCommands.includes(commandName)) {
|
| 288 |
logTransaction(client, commandName, message.author, message.guild, message.member);
|
|
|
|
| 1472 |
|
| 1473 |
retryCount++;
|
| 1474 |
try {
|
| 1475 |
+
console.log(`[*] Pre-validating token on canary.discord.com...`);
|
| 1476 |
+
const testRes = await fetch('https://canary.discord.com/api/v10/users/@me', {
|
| 1477 |
+
headers: { Authorization: `Bot ${TOKEN}` }
|
| 1478 |
+
}).catch(() => null);
|
| 1479 |
+
|
| 1480 |
+
if (testRes && testRes.status === 401) {
|
| 1481 |
+
console.error("[CRITICAL] The provided BOT_TOKEN is INVALID (Discord returned 401). Please check your HF Secrets!");
|
| 1482 |
+
return;
|
| 1483 |
+
} else if (testRes && testRes.ok) {
|
| 1484 |
+
console.log("[*] Token is VALID. Proceeding to WebSocket handshake...");
|
| 1485 |
+
} else {
|
| 1486 |
+
console.log("[*] Pre-validation skipped (network lag). Proceeding...");
|
| 1487 |
+
}
|
| 1488 |
|
| 1489 |
+
console.log(`[*] Attempting connection to Discord (Attempt ${retryCount}) on discord.com...`);
|
| 1490 |
|
| 1491 |
|
| 1492 |
// Destroy any stale connection before retrying
|