Add automatic creation of vote message with random movies #16

Merged
kenobi merged 11 commits from feat/voting into master 2023-06-12 21:00:17 +02:00
3 changed files with 6 additions and 4 deletions
Showing only changes of commit 0d5c3d30a9 - Show all commits

View File

@ -16,7 +16,7 @@ export default new Command({
const guildId = command.guildId!
logger.info("Got command for closing poll!", { guildId: guildId, requestId })
if (!command.guild) {
logger.error("No guild found in interaction. Cancelling closing request")
logger.error("No guild found in interaction. Cancelling closing request", {guildId: guildId, requestId})
command.followUp("Es gab leider ein Problem. Ich konnte deine Anfrage nicht bearbeiten :(")
return
}
@ -68,6 +68,7 @@ async function updateMessage(movie: string, message: Message, guildId: string, r
const options: MessageEditOptions = {
content: body,
}
logger.info("Updating message.", {guildId: guildId, requestId})
message.edit(options)
}
@ -90,6 +91,7 @@ async function updateEvent(votes: Vote[], guild: Guild, guildId: string, request
description: `!wp\nNummer 2: ${votes[1].movie} mit ${votes[1].count - 1} Stimmen\nNummer 3: ${votes[2].movie} mit ${votes[2].count - 1} Stimmen`
}
logger.debug(`Updating event: ${JSON.stringify(voteEvent, null, 2)}`, { guildId: guildId, requestId })
logger.info("Updating event.", {guildId: guildId, requestId})
voteEvent.edit(options)
kenobi marked this conversation as resolved
Review

My EYES!

My EYES!
Review

Sorry :( That's what you get with typing I guess?

Sorry :( That's what you get with typing I guess?
Review

All good :)

All good :)
}
@ -101,7 +103,7 @@ type Vote = {
async function getVotesByEmote(message: Message, guildId: string, requestId: string): Promise<Vote[]> {
const votes: Vote[] = []
logger.debug(`Number of items in emotes: ${Object.values(Emotes).length}`)
logger.debug(`Number of items in emotes: ${Object.values(Emotes).length}`, {guildId: guildId, requestId})
for (let i = 0; i < Object.keys(Emotes).length / 2; i++) {
const emote = Emotes[i]
logger.debug(`Getting reaction for emote ${emote}`, { guildId: guildId, requestId })

View File

@ -27,7 +27,7 @@ export async function execute(event: GuildScheduledEvent) {
logger.debug(`Movies: ${JSON.stringify(movies.map(movie => movie.name))}`, { guildId: event.guildId, requestId })
const channel: TextChannel = <TextChannel>(await event.guild?.channels.fetch())?.filter(channel => channel!.id === config.bot.announcement_channel_id).map((value, _) => value)[0] //todo: needs to be done less sketchy
kenobi marked this conversation as resolved
Review

Might present a good reason to fetch this channel during boot and keep it in a constant, so these kinds of searches don't have to be performed more than once.

Might present a good reason to fetch this channel during boot and keep it in a constant, so these kinds of searches don't have to be performed more than once.
Review

fixed

fixed
logger.debug(`Found channel ${JSON.stringify(channel, null, 2)}`)
logger.debug(`Found channel ${JSON.stringify(channel, null, 2)}`, { guildId: event.guildId, requestId })
let message = "[Abstimmung]\nEs gibt eine neue Abstimmung für die nächste Watchparty! Stimme hierunter für den nächsten Film ab!\n"

View File

@ -248,7 +248,7 @@ export class JellyfinHandler {
logger.info(`${count} random movies requested.`, { guildId: guildId, requestId })
const allMovies = await this.getAllMovies(guildId, requestId)
if (count >= allMovies.length) {
logger.info(`${count} random movies requested but found only ${allMovies.length}. Returning all Movies.`)
logger.info(`${count} random movies requested but found only ${allMovies.length}. Returning all Movies.`, { guildId: guildId, requestId })
return allMovies
}
const movies: BaseItemDto[] = []