completionId: cgen-a6ed9af59a90456bbc5cf0379fe4b668
cgen-a6ed9af59a90456bbc5cf0379fe4b668
This commit is contained in:
parent
a8b8b99bf9
commit
00dffd8df7
1 changed files with 35 additions and 0 deletions
|
|
@ -110,6 +110,41 @@ client.on("interactionCreate", async (interaction) => {
|
||||||
// This prevents Error 50240 (Entry Point conflict) when Activities are enabled
|
// This prevents Error 50240 (Entry Point conflict) when Activities are enabled
|
||||||
// The bot will simply load and listen for the already-registered commands
|
// The bot will simply load and listen for the already-registered commands
|
||||||
|
|
||||||
|
// Start HTTP health check server
|
||||||
|
const healthPort = process.env.HEALTH_PORT || 3000;
|
||||||
|
http
|
||||||
|
.createServer((req, res) => {
|
||||||
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
|
||||||
|
res.setHeader("Content-Type", "application/json");
|
||||||
|
|
||||||
|
if (req.method === "OPTIONS") {
|
||||||
|
res.writeHead(200);
|
||||||
|
res.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.url === "/health") {
|
||||||
|
res.writeHead(200);
|
||||||
|
res.end(
|
||||||
|
JSON.stringify({
|
||||||
|
status: "online",
|
||||||
|
guilds: client.guilds.cache.size,
|
||||||
|
commands: client.commands.size,
|
||||||
|
uptime: Math.floor(process.uptime()),
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.writeHead(404);
|
||||||
|
res.end(JSON.stringify({ error: "Not found" }));
|
||||||
|
})
|
||||||
|
.listen(healthPort, () => {
|
||||||
|
console.log(`🏥 Health check server running on port ${healthPort}`);
|
||||||
|
});
|
||||||
|
|
||||||
client.login(process.env.DISCORD_BOT_TOKEN);
|
client.login(process.env.DISCORD_BOT_TOKEN);
|
||||||
|
|
||||||
client.once("ready", () => {
|
client.once("ready", () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue