feat: implement administrative control panel with real-time bot actions

This commit is contained in:
syntaxbullet
2026-01-08 21:19:16 +01:00
parent 3f3a6c88e8
commit 0f6cce9b6e
14 changed files with 499 additions and 47 deletions

View File

@@ -97,6 +97,35 @@ export async function createWebServer(config: WebServerConfig = {}): Promise<Web
}
}
// Administrative Actions
if (url.pathname.startsWith("/api/actions/") && req.method === "POST") {
try {
const { actionService } = await import("@shared/modules/admin/action.service");
if (url.pathname === "/api/actions/reload-commands") {
const result = await actionService.reloadCommands();
return Response.json(result);
}
if (url.pathname === "/api/actions/clear-cache") {
const result = await actionService.clearCache();
return Response.json(result);
}
if (url.pathname === "/api/actions/maintenance-mode") {
const body = await req.json() as { enabled: boolean; reason?: string };
const result = await actionService.toggleMaintenanceMode(body.enabled, body.reason);
return Response.json(result);
}
} catch (error) {
console.error("Error executing administrative action:", error);
return Response.json(
{ error: "Failed to execute administrative action" },
{ status: 500 }
);
}
}
// Static File Serving
let pathName = url.pathname;
if (pathName === "/") pathName = "/index.html";
@@ -227,6 +256,7 @@ export async function createWebServer(config: WebServerConfig = {}): Promise<Web
})),
uptime: clientStats.uptime,
lastCommandTimestamp: clientStats.lastCommandTimestamp,
maintenanceMode: (await import("../../bot/lib/BotClient")).AuroraClient.maintenanceMode,
};
}