From 63e86bb70daf1b718778c841b8f8b4dd448f2230 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 9 Nov 2025 04:58:20 +0000 Subject: [PATCH] completionId: cgen-c4c730afe5694df69b9b8ee1b0ab592c cgen-c4c730afe5694df69b9b8ee1b0ab592c --- discord-bot/bot.js | 187 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 170 insertions(+), 17 deletions(-) diff --git a/discord-bot/bot.js b/discord-bot/bot.js index 507a2f88..e2428b56 100644 --- a/discord-bot/bot.js +++ b/discord-bot/bot.js @@ -256,28 +256,181 @@ http return; } - if (req.url === "/register-commands" && req.method === "POST") { - // Verify admin token if provided - const authHeader = req.headers.authorization; - const adminToken = process.env.DISCORD_ADMIN_REGISTER_TOKEN; + if (req.url === "/register-commands") { + if (req.method === "GET") { + // Show HTML form with button + res.writeHead(200, { "Content-Type": "text/html" }); + res.end(` + + + + Register Discord Commands + + + +
+

🤖 Discord Commands Registration

+

Click the button below to register all Discord slash commands (/verify, /set-realm, /profile, /unlink, /verify-role)

- if (adminToken && authHeader !== `Bearer ${adminToken}`) { - res.writeHead(401); - res.end(JSON.stringify({ error: "Unauthorized" })); + + +
⏳ Registering... please wait...
+
+
+ + + + + `); return; } - // Register commands - registerDiscordCommands().then((result) => { - if (result.success) { - res.writeHead(200); - res.end(JSON.stringify(result)); - } else { - res.writeHead(500); - res.end(JSON.stringify(result)); + if (req.method === "POST") { + // Verify admin token if provided + const authHeader = req.headers.authorization; + const adminToken = process.env.DISCORD_ADMIN_REGISTER_TOKEN; + + if (adminToken && authHeader !== `Bearer ${adminToken}`) { + res.writeHead(401); + res.end(JSON.stringify({ error: "Unauthorized" })); + return; } - }); - return; + + // Register commands + registerDiscordCommands().then((result) => { + if (result.success) { + res.writeHead(200); + res.end(JSON.stringify(result)); + } else { + res.writeHead(500); + res.end(JSON.stringify(result)); + } + }); + return; + } } res.writeHead(404);