function buildEmbed(state: PollState, options?: PollEmbedOptions): EmbedBuilder { const yesByNation: Record = { [Nation.Capella]: [], [Nation.Procyon]: [], }; const noVoters: VoteEntry[] = []; const allMessages: { entry: VoteEntry; voteType: "yes" | "no" }[] = []; const showNoInline = Config.get({ section: "poll", key: "showNoInNationField" }); for (const entry of state.yes.values()) { const nation = entry.characterNation ?? Nation.Capella; yesByNation[nation].push(entry); allMessages.push({ entry, voteType: "yes" }); } for (const entry of state.no.values()) { noVoters.push(entry); allMessages.push({ entry, voteType: "no" }); } const capellaEmoji = Emoji.get("capella"); const procyonEmoji = Emoji.get("procyon"); const embed = new EmbedBuilder() .setTitle(resolveTitle(state, yesByNation)) .setColor(resolveColor(state)) .addFields( { name: `${capellaEmoji} Capella (${yesByNation[Nation.Capella].length})`, value: formatNationField(Nation.Capella, yesByNation[Nation.Capella], noVoters, showNoInline), inline: false, }, { name: "\u200b", value: "\u200b", inline: false }, { name: `${procyonEmoji} Procyon (${yesByNation[Nation.Procyon].length})`, value: formatNationField(Nation.Procyon, yesByNation[Nation.Procyon], noVoters, showNoInline), inline: false, }, ) .setTimestamp(); const msgSection = formatMessages(allMessages); if (msgSection) { embed.addFields({ name: "\u200b", value: msgSection, inline: false }); } embed.setFooter({ text: resolveFooter(state, noVoters.length, options?.overrideLockMsg) }); return embed; }