From 16a9709e38f8b8928a7976a0d872149837ba35e2 Mon Sep 17 00:00:00 2001 From: sirpiglr <49359077-sirpiglr@users.noreply.replit.com> Date: Mon, 8 Dec 2025 02:49:32 +0000 Subject: [PATCH] Add feature to create server invite links Adds a new GET endpoint, /create-invite/:guildId, to the bot's HTTP server. This endpoint allows authorized administrators to generate a single-use invite link for a specified guild. Replit-Commit-Author: Agent Replit-Commit-Session-Id: aed2e46d-25bb-4b73-81a1-bb9e8437c261 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: af6c36e5-b176-44d7-a9c3-471f295835ca Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3bdfff67-975a-46ad-9845-fbb6b4a4c4b5/aed2e46d-25bb-4b73-81a1-bb9e8437c261/qURK7i9 Replit-Helium-Checkpoint-Created: true --- aethex-bot/bot.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/aethex-bot/bot.js b/aethex-bot/bot.js index 699c0be..af1f93f 100644 --- a/aethex-bot/bot.js +++ b/aethex-bot/bot.js @@ -644,6 +644,41 @@ http return; } + if (req.url.startsWith("/create-invite/") && req.method === "GET") { + if (!checkAdminAuth(req)) { + res.writeHead(401); + res.end(JSON.stringify({ error: "Unauthorized - Admin token required" })); + return; + } + + const guildId = req.url.split("/create-invite/")[1]; + (async () => { + try { + const guild = client.guilds.cache.get(guildId); + if (!guild) { + res.writeHead(404); + res.end(JSON.stringify({ error: "Guild not found" })); + return; + } + + const channel = guild.channels.cache.find(ch => ch.type === ChannelType.GuildText && ch.permissionsFor(guild.members.me).has('CreateInstantInvite')); + if (!channel) { + res.writeHead(403); + res.end(JSON.stringify({ error: "No channel available to create invite" })); + return; + } + + const invite = await channel.createInvite({ maxAge: 86400, maxUses: 1 }); + res.writeHead(200); + res.end(JSON.stringify({ success: true, invite: invite.url, guild: guild.name, expiresIn: "24 hours" })); + } catch (error) { + res.writeHead(500); + res.end(JSON.stringify({ error: error.message })); + } + })(); + return; + } + if (req.url === "/register-commands") { if (req.method === "GET") { if (!checkAdminAuth(req)) {