feat: implement administrative control panel with real-time bot actions
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user