import { renderToString } from "react-dom/server"; import type { MessageRecord } from "../moderation/types"; import type { ChannelSummary, GuildSummary, VoiceChannelSummary, VoiceStatus } from "../voiceController"; interface DashboardProps { guilds: GuildSummary[]; voiceChannels: VoiceChannelSummary[]; watchChannels: ChannelSummary[]; selectedGuildId: string; selectedChannelId: string; messages: MessageRecord[]; status: VoiceStatus; } function parseMetadata(value: string | null): any { if (!value) return {}; try { return JSON.parse(value); } catch { return {}; } } function safeJson(value: unknown): string { return JSON.stringify(value).replace(/
{message.avatar_url ? : null}
{message.username || message.user_id}
{new Date(message.created_at).toLocaleString()}
{content}
{metadata.stickers?.length ? (
{metadata.stickers.map((sticker: any) => ( {sticker.name} ))}
) : null} {metadata.embeds?.length ? (
{metadata.embeds.map((embed: any, index: number) => (
{embed.title ? ( embed.url ? ( {embed.title} ) : (
{embed.title}
) ) : null} {embed.description ?
{embed.description}
: null} {embed.fields?.map((field: any, fieldIndex: number) => (
{field.name}: {field.value}
))} {embed.image || embed.thumbnail ? ( {embed.title ) : null}
))}
) : null} {metadata.attachments?.length ? (
{metadata.attachments.map((attachment: any) => ( {attachment.name} ({(attachment.size / 1024).toFixed(1)}KB) ))}
) : null}
{metadata.reference?.messageId ? reply : null} {message.thread_id ? ( {metadata.channel?.threadName ? `thread: ${metadata.channel.threadName}` : "thread"} ) : null} {message.edited_at ? edited : null} {message.deleted_at ? deleted : null}
); } function DashboardPage(props: DashboardProps) { return (
Discord moderation command center

Voice. Text. One Watch Floor.

Single-page watcher for live voice bridge and captured Discord messages, including stickers, embeds, replies, and uploaded image evidence inline.

WebSocketConnecting
Voice Link{props.status.connected ? props.status.activeChannelName || "Connected" : "Not connected"}
Active TabVoice

Voice Control

bridge
{props.status.connected ? `Connected to ${props.status.activeChannelName}` : "Idle"}

Live Audio

speaker off

Participants

speaking now

Text Watch

create / edit / delete
{!props.selectedChannelId ?
Select channel to view text captures
: null} {props.selectedChannelId && props.messages.length === 0 ?
No text captures yet
: null} {props.messages.map((message) => )}
); } export function renderDashboardPage(props: DashboardProps): string { const app = renderToString(); const bootstrap = safeJson({ guilds: props.guilds, voiceChannels: props.voiceChannels, watchChannels: props.watchChannels, selectedGuildId: props.selectedGuildId, selectedChannelId: props.selectedChannelId, messages: props.messages, status: props.status, }); return ` Discord Moderation Watcher
${app}
`; }