export async function handleRankPost(interaction: ChatInputCommandInteraction): Promise { const week = getCurrentWeek(); const goal = cfg("wRankGoal"); const weekKey = getWeekKey(); const formatNation = (nation: "capella" | "procyon"): string => { const entries = [...week.entries[nation]].sort((a, b) => a.currentRank - b.currentRank); if (entries.length === 0) return "—"; const bringer = getBringer(nation === "capella" ? Nation.Capella : Nation.Procyon); return entries.map((e) => { const isDone = e.tgCount >= goal; // ── Character indicator ─────────────────────────────────────────────────── const char = CharacterRegistry.find(e.characterName); console.log(`[rank/post.ts:] char: ${char}`); const charStr = char ? format.char(char) : `${e.class} ${e.characterName}`; // const charStr = format.char({ class: e.class, level: 78, name: e.characterName }); // ── Rank indicator ─────────────────────────────────────────────────── const rankStr = format.wrank.rank(e, goal); const deltaStr = format.wrank.delta(e, { brackets: false }); // ── Bringer label ──────────────────────────────────────────────────── const bringerStr = bringer === e.userKey && isDone ? ` · ${nation === "capella" ? "Luminous Bringer" : "Storm Bringer"}` : ""; // ── Score indicator ─────────────────────────────────────────────────── const scoreStr = format.score(e.weeklyPoints); return `${rankStr}(${deltaStr}) ${charStr} — ${scoreStr} ${bringerStr}`; }).join("\n"); // return `${rankStr}(${deltaStr}) ${e.characterName} — ${e.weeklyPoints} pts (${e.tgCount}/${goal}${bringerStr})`; // }).join("\n"); }; const embed = new EmbedBuilder() .setTitle(`⚔️ TG Leaderboard — ${weekKey}`) .setColor(0xe8a317) .addFields( { name: format.nation("Capella"), value: formatNation("capella"), inline: true }, { name: format.nation("Procyon"), value: formatNation("procyon"), inline: true }, ) .setTimestamp(); const channelId = cfg("resultsChannelId") || cfg("pollChannelId"); const channel = await interaction.client.channels.fetch(channelId) as TextChannel; await channel.send({ embeds: [embed] }); return void replyAndDelete(interaction, "✅ Leaderboard posted."); }