export const Leaderboard = { /** * Build and post/edit the leaderboard for the current week. * Called after each score submission and on weekly reset. */ async update({ weekKey }: { weekKey?: string } = {}): Promise { const client = DiscordClient.get(); const channelId = Config.get({ section: "channels", key: "leaderboard" }); if (!channelId) { log.warn("leaderboard channel not configured"); return; } const week = weekKey ? WRank.weekFromKey(weekKey) : WRank.currentWeek(); if (!week) { log.warn(`Week ${weekKey} not found`); return; } const embed = LeaderboardUI.buildEmbed(week, entries as any); await PersistentMessage.post({ store: "leaderboard", key: week.weekKey, channelId, embeds: [embed], client, }); log.info(`Leaderboard updated for ${week.weekKey}`); }, };