fedimbed.polls: round percents, add counts

This commit is contained in:
Cynthia Foxwell 2023-11-25 12:34:28 -07:00
parent 0e4aa68fc9
commit c4f8d53321

View file

@ -623,12 +623,14 @@ async function processUrl(msg, url, spoiler = false) {
const percent = o.count / poll.total; const percent = o.count / poll.total;
const bar = Math.round(percent * 30); const bar = Math.round(percent * 30);
return `**${o.name}** (${(percent * 100).toFixed( return `**${o.name}** (${o.count}, ${Math.round(
2 percent * 100
)}%)\n\`[${"=".repeat(bar)}${" ".repeat(30 - bar)}]\``; )}%)\n\`[${"=".repeat(bar)}${" ".repeat(30 - bar)}]\``;
}) })
.join("\n\n") + .join("\n\n") +
`\n\nEnds: <t:${Math.floor(poll.end.getTime() / 1000)}:R>`, `\n\n${poll.total} votes \u2022 Ends <t:${Math.floor(
poll.end.getTime() / 1000
)}:R>`,
}); });
} }