remove duplicate check for none_of_that vote

This commit is contained in:
kenobi 2023-06-27 20:22:44 +02:00
parent 98d1ca73b5
commit 3f071c8a4e

View File

@ -10,24 +10,19 @@ export default class VoteController {
public async handleNoneOfThatVote(messageReaction: MessageReaction, user: User, reactedUponMessage: Message, requestId: string, guildId: string) { public async handleNoneOfThatVote(messageReaction: MessageReaction, user: User, reactedUponMessage: Message, requestId: string, guildId: string) {
if (!messageReaction.message.guild) return 'No guild' if (!messageReaction.message.guild) return 'No guild'
if (messageIsVoteMessage(reactedUponMessage)) { logger.debug(`${reactedUponMessage.id} is vote message`, { requestId, guildId })
logger.debug(`${reactedUponMessage.id} is vote message`, { requestId, guildId }) const watcherRoleMember = await getMembersWithRoleFromGuild(config.bot.announcement_role, messageReaction.message.guild)
if (messageReaction.message.reactions.cache.find(reaction => reaction.emoji.toString() == NONE_OF_THAT)) { logger.info("ROLE MEMBERS " + JSON.stringify(watcherRoleMember), { requestId, guildId })
const watcherRoleMember = await getMembersWithRoleFromGuild(config.bot.announcement_role, messageReaction.message.guild) const watcherRoleMemberCount = watcherRoleMember.size
logger.info("ROLE MEMBERS " + JSON.stringify(watcherRoleMember), { requestId, guildId }) logger.info(`MEMBER COUNT: ${watcherRoleMemberCount}`, { requestId, guildId })
const watcherRoleMemberCount = watcherRoleMember.size let noneOfThatReactions = messageReaction.message.reactions.cache.get(NONE_OF_THAT)?.users.cache.filter(x => x.id !== client.user?.id).size ?? 0
logger.info(`MEMBER COUNT: ${watcherRoleMemberCount}`, { requestId, guildId })
let noneOfThatReactions = messageReaction.message.reactions.cache.get(NONE_OF_THAT)?.users.cache.filter(x => x.id !== client.user?.id).size ?? 0
const memberThreshold = (watcherRoleMemberCount / 2) const memberThreshold = (watcherRoleMemberCount / 2)
logger.info(`Reroll ${noneOfThatReactions} > ${memberThreshold} ?`, { requestId, guildId }) logger.info(`Reroll ${noneOfThatReactions} > ${memberThreshold} ?`, { requestId, guildId })
if (noneOfThatReactions > memberThreshold) { if (noneOfThatReactions > memberThreshold) {
logger.info('Starting poll reroll', { requestId, guildId }) logger.info('Starting poll reroll', { requestId, guildId })
messageReaction.message.edit((messageReaction.message.content ?? "").concat('\nDiese Abstimmung muss wiederholt werden.')) messageReaction.message.edit((messageReaction.message.content ?? "").concat('\nDiese Abstimmung muss wiederholt werden.'))
}
logger.info(`No reroll`, { requestId, guildId })
}
} }
logger.info(`No reroll`, { requestId, guildId })
} }
} }