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)) {