fedimbed: poll time awareness

This commit is contained in:
Cynthia Foxwell 2025-04-17 22:03:45 -06:00
parent 66aa9cc1c7
commit 9f5ebe42fa
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -1509,6 +1509,8 @@ async function processUrl(msg, url, spoiler = false, command = false) {
} }
if (poll) { if (poll) {
const pollTime = poll.end.getTime();
const now = Date.now();
baseEmbed.fields.push({ baseEmbed.fields.push({
name: "Poll", name: "Poll",
value: value:
@ -1521,7 +1523,8 @@ async function processUrl(msg, url, spoiler = false, command = false) {
percent * 100 percent * 100
)}%)\n\`${"\u2588".repeat(bar)}${" ".repeat(32 - bar)}\``; )}%)\n\`${"\u2588".repeat(bar)}${" ".repeat(32 - bar)}\``;
}) })
.join("\n\n") + `\n\n${poll.total} votes \u2022 Ends <t:${Math.floor(poll.end.getTime() / 1000)}:R>`, .join("\n\n") +
`\n\n${poll.total} votes \u2022 End${pollTime > now ? "s" : "ed"} <t:${Math.floor(pollTime / 1000)}:R>`,
}); });
} }