import { BaseLayout } from "../views/layout"; import { AuroraClient } from "@/lib/BotClient"; import { getRecentLogs } from "@/lib/logger"; export function dashboardRoute(): Response { // Gather real data const guildCount = AuroraClient.guilds.cache.size; const userCount = AuroraClient.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0); const commandCount = AuroraClient.commands.size; const ping = AuroraClient.ws.ping; // Real system metrics const memUsage = process.memoryUsage(); const memoryUsage = (memUsage.heapUsed / 1024 / 1024).toFixed(2); const memoryTotal = (memUsage.rss / 1024 / 1024).toFixed(1); const uptimeSeconds = process.uptime(); const uptime = new Date(uptimeSeconds * 1000).toISOString().substr(11, 8); // HH:MM:SS const startTimestamp = Date.now() - (uptimeSeconds * 1000); // Real activity logs const activityLogs = getRecentLogs(); const memPercent = Math.min(100, (memUsage.heapUsed / memUsage.rss) * 100).toFixed(1); // Get top guilds const topGuilds = AuroraClient.guilds.cache .sort((a, b) => b.memberCount - a.memberCount) .first(5); const content = `

Members

${userCount.toLocaleString()}
Total user reach

Guilds

${guildCount}
Active connections

Latency

${ping < 0 ? "?" : ping}ms
${ping < 100 ? "Stable" : "High"}

Activity Flow

Live
    ${activityLogs.length > 0 ? activityLogs.map(log => `
  • ${log.time} ${log.message}
  • `).join('') : `
  • Listening for activity...
  • `}

Health

Memory ${memoryUsage} MB
Uptime ${uptime}

Top Guilds

${topGuilds.map(g => `
${g.name} ${g.memberCount} members
`).join('')}

Quick Actions

`; const html = BaseLayout({ title: "Dashboard", content }); return new Response(html, { headers: { "Content-Type": "text/html" }, }); }