Compare commits

...

4 Commits

Author SHA1 Message Date
8ff5aeff03 logging
All checks were successful
Compile the repository / compile (pull_request) Successful in 1m21s
Run unit tests / test (pull_request) Successful in 1m26s
2023-08-06 02:33:28 +02:00
1101a84501 imports 2023-08-06 02:33:23 +02:00
91ec2ece7e explicit typing 2023-08-06 02:33:17 +02:00
5e58765cf4 also enabled NONE_OF_THAT to be handled 2023-08-06 02:32:44 +02:00
2 changed files with 9 additions and 8 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())) {
if (!Object.values(Emotes).includes(messageReaction.emoji.toString()) && messageReaction.emoji.toString() !== NONE_OF_THAT) {
logger.info(`${messageReaction.emoji.toString()} currently not handled`)
return
}

View File

@ -1,5 +1,5 @@
import { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, MessageReaction, PartialMessage, TextChannel, User } from "discord.js"
import { Emoji, Emotes, NONE_OF_THAT } from "../constants"
import { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, MessageReaction, TextChannel } from "discord.js"
import { Emotes, NONE_OF_THAT } from "../constants"
import { logger, newRequestId } from "../logger"
import { getMembersWithRoleFromGuild } from "./roleFilter"
import { config } from "../configuration"
@ -13,7 +13,6 @@ 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
@ -54,18 +53,20 @@ 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 = await this.parseVoteInfoFromVoteMessage(voteMessage, requestId)
const voteInfo: VoteMessageInfo = await this.parseVoteInfoFromVoteMessage(voteMessage, requestId)
// get movies from jellyfin to fill the remaining slots
const newMovieCount = config.bot.random_movie_count - voteInfo.votes.filter(x => x.count > 2).length
const newMovies = await this.yavinJellyfinHandler.getRandomMovieNames(newMovieCount, guildId, requestId)
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)
// merge
const movies = newMovies.concat(voteInfo.votes.map(x => x.movie))
const movies: string[] = newMovies.concat(voteInfo.votes.map(x => x.movie))
// create new message
await this.closePoll(guild, requestId)