From 25c79fabc7c0cc89784b12037f585c8c7ce9e44a Mon Sep 17 00:00:00 2001 From: Delemangi Date: Sun, 12 Nov 2023 16:00:12 +0100 Subject: [PATCH] Update poll threshold formula --- src/utils/polls.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/polls.ts b/src/utils/polls.ts index 39b00369..d149328f 100644 --- a/src/utils/polls.ts +++ b/src/utils/polls.ts @@ -158,7 +158,11 @@ export const getPollThreshold = async (pollId: string) => { } const totalVoters = await getMembersWithRoles(guild, ...poll.roles); - const rawThreshold = totalVoters.length * poll.threshold; + const abstenstions = await countPollVotesByOptionId( + poll.options.find((option) => option.name === "Воздржан")?.id ?? "", + ); + const rawThreshold = + (totalVoters.length - (abstenstions ?? 0)) * poll.threshold; const threshold = Number.isInteger(rawThreshold) ? rawThreshold + 1 : Math.ceil(rawThreshold); @@ -169,11 +173,7 @@ export const getPollThreshold = async (pollId: string) => { return threshold; } - const abstenstions = await countPollVotesByOptionId( - poll.options.find((option) => option.name === "Воздржан")?.id ?? "", - ); - - return threshold - (abstenstions ?? 0); + return threshold; }; export const decidePoll = async (pollId: string) => {