From c933d8523292d280cc43bcf5bea2d859e6e31215 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 8 Nov 2025 20:51:06 +0000 Subject: [PATCH] completionId: cgen-ad565a61bc6047fd9c5f2b736d564a4f cgen-ad565a61bc6047fd9c5f2b736d564a4f --- discord-bot/bot.js | 62 +++++++++++----------------------------------- 1 file changed, 15 insertions(+), 47 deletions(-) diff --git a/discord-bot/bot.js b/discord-bot/bot.js index 58837744..67a14f69 100644 --- a/discord-bot/bot.js +++ b/discord-bot/bot.js @@ -104,56 +104,24 @@ client.on("interactionCreate", async (interaction) => { } }); -// Register slash commands with Discord API -async function registerCommands() { - try { - const commands = []; - for (const command of client.commands.values()) { - commands.push(command.data.toJSON()); - } +// IMPORTANT: Commands are now registered via a separate script +// Run this ONCE during deployment: npm run register-commands +// This prevents Error 50240 (Entry Point conflict) when Activities are enabled +// The bot will simply load and listen for the already-registered commands - const rest = new REST({ version: "10" }).setToken( - process.env.DISCORD_BOT_TOKEN, - ); - - console.log(`📝 Registering ${commands.length} slash commands...`); - - try { - const data = await rest.put( - Routes.applicationCommands(process.env.DISCORD_CLIENT_ID), - { body: commands }, - ); - console.log(`✅ Successfully registered ${data.length} slash commands.`); - } catch (error) { - // Handle Entry Point command conflict (Discord Activity) - if (error.code === 50240) { - console.warn( - "âš ī¸ Entry Point command detected (Discord Activity). Attempting to register without bulk update...", - ); - // Post commands individually to avoid bulk update conflicts - for (const command of commands) { - await rest.post( - Routes.applicationCommands(process.env.DISCORD_CLIENT_ID), - { body: command }, - ); - } - console.log( - `✅ Successfully registered ${commands.length} slash commands (individual).`, - ); - } else { - throw error; - } - } - } catch (error) { - console.error("❌ Error registering commands:", error.message || error); - } -} - -// Login and register commands client.login(process.env.DISCORD_BOT_TOKEN); -client.once("ready", async () => { - await registerCommands(); +client.once("ready", () => { + console.log(`✅ Bot logged in as ${client.user.tag}`); + console.log(`📡 Listening in ${client.guilds.cache.size} server(s)`); + console.log( + "â„šī¸ Commands are registered via: npm run register-commands" + ); + + // Set bot status + client.user.setActivity("/verify to link your AeThex account", { + type: "LISTENING", + }); }); // Error handling