Compare commits
No commits in common. "a455fd8ff7e6b8ffb032fb4aed9389da68ee513b" and "66507cb08fa50ba3a7be28388c55b21227fb2261" have entirely different histories.
a455fd8ff7
...
66507cb08f
@ -63,20 +63,18 @@ export default class VoteController {
|
||||
}
|
||||
return await message.delete()
|
||||
}
|
||||
|
||||
public hasAtLeastOneVote(vote: Vote): boolean {
|
||||
// subtracting the bots initial vote
|
||||
const overOneVote = (vote.count - 1) >= 1
|
||||
logger.debug(`${vote.movie} : ${vote.count} -> above: ${overOneVote}`)
|
||||
return overOneVote
|
||||
public isAboveThreshold(vote: Vote): boolean {
|
||||
const aboveThreshold = (vote.count - 1) >= 1
|
||||
logger.debug(`${vote.movie} : ${vote.count} -> above: ${aboveThreshold}`)
|
||||
return aboveThreshold
|
||||
}
|
||||
public async handleReroll(voteMessage: VoteMessage, guildId: string, requestId: string) {
|
||||
// get the movies currently being voted on, their votes, the eventId and its date
|
||||
//get movies that already had votes to give them a second chance
|
||||
const voteInfo: VoteMessageInfo = await this.parseVoteInfoFromVoteMessage(voteMessage, requestId)
|
||||
|
||||
let movies: string[] = Array()
|
||||
if (config.bot.reroll_retains_top_picks) {
|
||||
const votedOnMovies = voteInfo.votes.filter(this.hasAtLeastOneVote).filter(x => x.emote !== NONE_OF_THAT)
|
||||
const votedOnMovies = voteInfo.votes.filter(this.isAboveThreshold).filter(x => x.emote !== NONE_OF_THAT)
|
||||
logger.info(`Found ${votedOnMovies.length} with votes`, { requestId, guildId })
|
||||
const newMovieCount: number = config.bot.random_movie_count - votedOnMovies.length
|
||||
logger.info(`Fetching ${newMovieCount} from jellyfin`)
|
||||
@ -92,7 +90,7 @@ export default class VoteController {
|
||||
// create new message
|
||||
|
||||
logger.info(`Creating new poll message with new movies: ${movies}`, { requestId, guildId })
|
||||
const messageText = this.createVoteMessageText(voteInfo.eventId, voteInfo.eventDate, movies, guildId, requestId)
|
||||
const message = this.createVoteMessageText(voteInfo.eventId, voteInfo.eventDate, movies, guildId, requestId)
|
||||
const announcementChannel = this.client.getAnnouncementChannelForGuild(guildId)
|
||||
if (!announcementChannel) {
|
||||
logger.error(`No announcementChannel found for ${guildId}, can't post poll`)
|
||||
@ -106,7 +104,7 @@ export default class VoteController {
|
||||
logger.error(`Error during removeMessage: ${err}`)
|
||||
}
|
||||
|
||||
const sentMessage = await this.sendVoteMessage(messageText, movies.length, announcementChannel)
|
||||
const sentMessage = await this.sendVoteMessage(message, movies.length, announcementChannel)
|
||||
sentMessage.pin()
|
||||
logger.info(`Sent and pinned new poll message`, { requestId, guildId })
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user