feat: purge status channel on startup for clean dashboard

- Add purgeChannel() to Channel interface and DiscordChannel
- Uses bulkDelete for recent messages, individual delete for old ones
- Called once at startup before creating fresh dashboard messages
This commit is contained in:
Eyejoker
2026-03-14 00:52:41 +09:00
parent d06a835163
commit 7a726c335d
3 changed files with 63 additions and 1 deletions

View File

@@ -756,7 +756,10 @@ async function buildUsageContent(): Promise<string> {
lines.push(`• 업타임: ${formatElapsed(os.uptime() * 1000)}`);
return lines.join('\n') + `\n\n_${new Date().toLocaleTimeString('ko-KR', { hour: '2-digit', minute: '2-digit' })}_`;
return (
lines.join('\n') +
`\n\n_${new Date().toLocaleTimeString('ko-KR', { hour: '2-digit', minute: '2-digit' })}_`
);
}
// ── Dashboard Lifecycle ─────────────────────────────────────────
@@ -1115,6 +1118,16 @@ async function main(): Promise<void> {
});
queue.setProcessMessagesFn(processGroupMessages);
recoverPendingMessages();
// Purge old messages in status channel before creating fresh dashboards
if (STATUS_CHANNEL_ID) {
const statusJid = `dc:${STATUS_CHANNEL_ID}`;
const ch = channels.find(
(c) => c.name.startsWith('discord') && c.isConnected() && c.purgeChannel,
);
if (ch?.purgeChannel) {
await ch.purgeChannel(statusJid);
}
}
await startStatusDashboard();
await startUsageDashboard();
startMessageLoop().catch((err) => {