Compare commits

..

No commits in common. "8ff5aeff03c00661470c68f9b9a1f5d2034249cf" and "a2adef808f26382c8980d777bcba30bb5334317a" have entirely different histories.

2 changed files with 8 additions and 9 deletions

View File

@ -26,7 +26,7 @@ export async function execute(messageReaction: MessageReaction, user: User) {
logger.info(`emoji: ${messageReaction.emoji.toString()}`)
if (!Object.values(Emotes).includes(messageReaction.emoji.toString()) && messageReaction.emoji.toString() !== NONE_OF_THAT) {
if (!Object.values(Emotes).includes(messageReaction.emoji.toString())) {
logger.info(`${messageReaction.emoji.toString()} currently not handled`)
return
}

View File

@ -1,5 +1,5 @@
import { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, MessageReaction, TextChannel } from "discord.js"
import { Emotes, NONE_OF_THAT } from "../constants"
import { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, MessageReaction, PartialMessage, TextChannel, User } from "discord.js"
import { Emoji, Emotes, NONE_OF_THAT } from "../constants"
import { logger, newRequestId } from "../logger"
import { getMembersWithRoleFromGuild } from "./roleFilter"
import { config } from "../configuration"
@ -13,6 +13,7 @@ import addDays from "date-fns/addDays"
import isAfter from "date-fns/isAfter"
import { ExtendedClient } from "../structures/client"
import { JellyfinHandler } from "../jellyfin/handler"
import { ObjectGroupUpdateToJSON } from "../jellyfin"
export type Vote = {
emote: string, //todo habs nicht hinbekommen hier Emotes zu nutzen
@ -53,20 +54,18 @@ export default class VoteController {
else
logger.info('Starting poll reroll', { requestId, guildId })
await this.handleReroll(reactedUponMessage, guild, guild.id, requestId)
logger.info(`Finished handling NONE_OF_THAT vote`, { requestId, guildId })
}
public async handleReroll(voteMessage: VoteMessage, guild: Guild, guildId: string, requestId: string) {
//get movies that already had votes to give them a second chance
const voteInfo: VoteMessageInfo = await this.parseVoteInfoFromVoteMessage(voteMessage, requestId)
const voteInfo = await this.parseVoteInfoFromVoteMessage(voteMessage, requestId)
// get movies from jellyfin to fill the remaining slots
const newMovieCount: number = config.bot.random_movie_count - voteInfo.votes.filter(x => x.count > 2).length
const newMovies: string[] = await this.yavinJellyfinHandler.getRandomMovieNames(newMovieCount, guildId, requestId)
const newMovieCount = config.bot.random_movie_count - voteInfo.votes.filter(x => x.count > 2).length
const newMovies = await this.yavinJellyfinHandler.getRandomMovieNames(newMovieCount, guildId, requestId)
// merge
const movies: string[] = newMovies.concat(voteInfo.votes.map(x => x.movie))
const movies = newMovies.concat(voteInfo.votes.map(x => x.movie))
// create new message
await this.closePoll(guild, requestId)