feat/40-reroll-on-disinterest #54

Merged
kenobi merged 73 commits from feat/40-reroll-on-disinterest into master 2023-11-19 20:24:36 +01:00
Showing only changes of commit fdfe7ce404 - Show all commits

View File

@ -13,7 +13,6 @@ import addDays from "date-fns/addDays"
import isAfter from "date-fns/isAfter"
kenobi marked this conversation as resolved Outdated

Move check to handleMessageReactionAdd

Move check to handleMessageReactionAdd

moved

moved
import { ExtendedClient } from "../structures/client"
import { JellyfinHandler } from "../jellyfin/handler"
kenobi marked this conversation as resolved Outdated

duplicate check. already checked before call in handleMessageReactionAdd

duplicate check. already checked before call in handleMessageReactionAdd

removed

removed
import { getYear } from "date-fns"
export type Vote = {
emote: string, //todo habs nicht hinbekommen hier Emotes zu nutzen
@ -76,6 +75,9 @@ export default class VoteController {
}
logger.info(`No reroll`, { requestId, guildId })
magnetotail marked this conversation as resolved Outdated

maybe extract this if-else to a method to keep code more compact

maybe extract this if-else to a method to keep code more compact

7d794a8001
done

7d794a8001a66d068f949c893d689a068c3caeed done
}
parseEventIdFromMessage(message: Message<boolean> | PartialMessage, requestId: string): string {
throw new Error("Method not implemented.")
}
private fetchEventStartDateByEventId(eventId: string, requestId: string): Date {
throw new Error("Method not implemented.")
}
@ -91,18 +93,16 @@ export default class VoteController {
if (!result) throw Error('No event url found in Message')
magnetotail marked this conversation as resolved Outdated

is not a message, only messagetext

is not a message, only messagetext
a455fd8ff7e6b8ffb032fb4aed9389da68ee513b

done

done
eventId = result?.[0].split('/').at(-1) ?? ""
} else if (!line.slice(0, 5).includes(':')) {
const datematcher = RegExp(/((0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012]))(\ um\ )(([012][0-9]:[0-5][0-9]))/i)
const result: RegExpMatchArray | null = line.match(datematcher)
const timeFromResult = result?.at(-1)
const dateFromResult = result?.at(1)?.concat(format(new Date(), '.yyyy')).concat(" " + timeFromResult) ?? ""
eventDate = new Date(dateFromResult)
eventDate = this.parseEventDateFromLine(line)
} else if (line.slice(0, 5).includes(':')) {
const splitLine = line.split(":")
const [emoji, movie] = splitLine
if (emoji === NONE_OF_THAT) continue
const fetchedVoteFromMessage = message.reactions.cache.get(emoji)
if (fetchedVoteFromMessage) {
votes.push({ movie:movie.trim(), emote: emoji, count: fetchedVoteFromMessage.count })
if (emoji === NONE_OF_THAT) {
votes.push({ movie: NONE_OF_THAT, emote: NONE_OF_THAT, count: fetchedVoteFromMessage.count })
} else
votes.push({ movie: movie.trim(), emote: emoji, count: fetchedVoteFromMessage.count })
} else {
logger.error(`No vote reaction found for movie, assuming 0`, requestId)
votes.push({ movie, emote: emoji, count: 0 })
magnetotail marked this conversation as resolved Outdated

why not pin message in method above?

why not pin message in method above?

7d794a8001
should have been moved to prepareAndSendVoteMessage()

7d794a8001a66d068f949c893d689a068c3caeed should have been moved to prepareAndSendVoteMessage()
@ -111,8 +111,12 @@ export default class VoteController {
}
return <VoteMessageInfo>{ eventId, eventDate, votes }
}
private parseEventIdFromMessage(message: Message<boolean> | PartialMessage, requestId: string): string {
throw new Error("Method not implemented.")
public parseEventDateFromLine(line: string): Date {
const datematcher = RegExp(/((0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012]))(\ um\ )(([012][0-9]:[0-5][0-9]))/i)
const result: RegExpMatchArray | null = line.match(datematcher)
const timeFromResult = result?.at(-1)
const dateFromResult = result?.at(1)?.concat(format(new Date(), '.yyyy')).concat(" " + timeFromResult) ?? ""
return new Date(dateFromResult)
}
public createVoteMessageText(eventId: string, eventStartDate: Date, movies: string[], guildId: string, requestId: string): string {