From 1e5e6481801595c432002da9cb61967df1c8c2b4 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 9 Nov 2025 07:10:07 +0000 Subject: [PATCH] completionId: cgen-7ed7b0861f9b41baa706d20d52c93f7e cgen-7ed7b0861f9b41baa706d20d52c93f7e --- server/index.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/server/index.ts b/server/index.ts index f3264647..d55d7f33 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1274,25 +1274,37 @@ export function createServer() { } } - const botToken = process.env.DISCORD_BOT_TOKEN; - const clientId = process.env.DISCORD_CLIENT_ID; + const botToken = process.env.DISCORD_BOT_TOKEN?.trim(); + const clientId = process.env.DISCORD_CLIENT_ID?.trim(); console.log( "[Discord] Config check - botToken set:", !!botToken, "clientId set:", !!clientId, + "botToken length:", + botToken?.length, ); + // Log first and last few chars of token for debugging (safe logging) + if (botToken) { + const first = botToken.substring(0, 5); + const last = botToken.substring(botToken.length - 5); + console.log( + "[Discord] Token preview: " + first + "..." + last, + "Total length:", + botToken.length, + ); + } + if (!botToken || !clientId) { return res.status(500).json({ error: "Discord bot token or client ID not configured", }); } - // Validate token format - Discord bot tokens are typically long strings - // They don't always have dots, but should be reasonably long - if (!botToken || botToken.trim().length < 20) { + // Validate token format + if (botToken.length < 20) { console.warn( "[Discord] Bot token appears invalid - length:", botToken.length,