Compare commits
4 Commits
a2adef808f
...
8ff5aeff03
Author | SHA1 | Date | |
---|---|---|---|
8ff5aeff03 | |||
1101a84501 | |||
91ec2ece7e | |||
5e58765cf4 |
@ -26,7 +26,7 @@ export async function execute(messageReaction: MessageReaction, user: User) {
|
|||||||
|
|
||||||
logger.info(`emoji: ${messageReaction.emoji.toString()}`)
|
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`)
|
logger.info(`${messageReaction.emoji.toString()} currently not handled`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, MessageReaction, PartialMessage, TextChannel, User } from "discord.js"
|
import { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, MessageReaction, TextChannel } from "discord.js"
|
||||||
import { Emoji, Emotes, NONE_OF_THAT } from "../constants"
|
import { Emotes, NONE_OF_THAT } from "../constants"
|
||||||
import { logger, newRequestId } from "../logger"
|
import { logger, newRequestId } from "../logger"
|
||||||
import { getMembersWithRoleFromGuild } from "./roleFilter"
|
import { getMembersWithRoleFromGuild } from "./roleFilter"
|
||||||
import { config } from "../configuration"
|
import { config } from "../configuration"
|
||||||
@ -13,7 +13,6 @@ import addDays from "date-fns/addDays"
|
|||||||
import isAfter from "date-fns/isAfter"
|
import isAfter from "date-fns/isAfter"
|
||||||
import { ExtendedClient } from "../structures/client"
|
import { ExtendedClient } from "../structures/client"
|
||||||
import { JellyfinHandler } from "../jellyfin/handler"
|
import { JellyfinHandler } from "../jellyfin/handler"
|
||||||
import { ObjectGroupUpdateToJSON } from "../jellyfin"
|
|
||||||
|
|
||||||
export type Vote = {
|
export type Vote = {
|
||||||
emote: string, //todo habs nicht hinbekommen hier Emotes zu nutzen
|
emote: string, //todo habs nicht hinbekommen hier Emotes zu nutzen
|
||||||
@ -54,18 +53,20 @@ export default class VoteController {
|
|||||||
else
|
else
|
||||||
logger.info('Starting poll reroll', { requestId, guildId })
|
logger.info('Starting poll reroll', { requestId, guildId })
|
||||||
await this.handleReroll(reactedUponMessage, guild, guild.id, requestId)
|
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) {
|
public async handleReroll(voteMessage: VoteMessage, guild: Guild, guildId: string, requestId: string) {
|
||||||
|
|
||||||
//get movies that already had votes to give them a second chance
|
//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
|
// 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 newMovieCount: number = config.bot.random_movie_count - voteInfo.votes.filter(x => x.count > 2).length
|
||||||
const newMovies = await this.yavinJellyfinHandler.getRandomMovieNames(newMovieCount, guildId, requestId)
|
const newMovies: string[] = await this.yavinJellyfinHandler.getRandomMovieNames(newMovieCount, guildId, requestId)
|
||||||
|
|
||||||
// merge
|
// 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
|
// create new message
|
||||||
await this.closePoll(guild, requestId)
|
await this.closePoll(guild, requestId)
|
||||||
|
Loading…
Reference in New Issue
Block a user