Fix loggers

Some logger messages were missing requestId and guildId
This commit is contained in:
Sammy 2023-06-10 22:58:00 +02:00
parent c2d8838cf8
commit 0d5c3d30a9
3 changed files with 6 additions and 4 deletions

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)
}
@ -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
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[] = []