removed unnecessary guildId: from logger calls

This commit is contained in:
Sammy 2023-06-12 20:36:05 +02:00
parent f3669ec34f
commit fdc0fc47b5
3 changed files with 21 additions and 21 deletions

View File

@ -15,9 +15,9 @@ export default new Command({
const command = interaction.interaction const command = interaction.interaction
const requestId = uuid() const requestId = uuid()
const guildId = command.guildId! const guildId = command.guildId!
logger.info("Got command for closing poll!", { guildId: guildId, requestId }) logger.info("Got command for closing poll!", { guildId, requestId })
if (!command.guild) { if (!command.guild) {
logger.error("No guild found in interaction. Cancelling closing request", {guildId: guildId, requestId}) logger.error("No guild found in interaction. Cancelling closing request", { guildId, requestId })
command.followUp("Es gab leider ein Problem. Ich konnte deine Anfrage nicht bearbeiten :(") command.followUp("Es gab leider ein Problem. Ich konnte deine Anfrage nicht bearbeiten :(")
return return
} }
@ -29,7 +29,7 @@ export default new Command({
export async function closePoll(guild: Guild, requestId: string) { export async function closePoll(guild: Guild, requestId: string) {
const guildId = guild.id const guildId = guild.id
logger.info("stopping poll", { guildId: guildId, requestId }) logger.info("stopping poll", { guildId, requestId })
const announcementChannel: TextChannel = client.getAnnouncementChannelForGuild(guildId) const announcementChannel: TextChannel = client.getAnnouncementChannelForGuild(guildId)
@ -39,20 +39,20 @@ export async function closePoll(guild: Guild, requestId: string) {
.sort((a, b) => b.createdTimestamp - a.createdTimestamp) .sort((a, b) => b.createdTimestamp - a.createdTimestamp)
if (!messages || messages.length <= 0) { if (!messages || messages.length <= 0) {
logger.info("Could not find any vote messages. Cancelling pollClose", { guildId: guildId, requestId }) logger.info("Could not find any vote messages. Cancelling pollClose", { guildId, requestId })
return return
} }
const lastMessage: Message<true> = messages[0] const lastMessage: Message<true> = messages[0]
logger.debug(`Found messages: ${JSON.stringify(messages, null, 2)}`, { guildId: guildId, requestId }) logger.debug(`Found messages: ${JSON.stringify(messages, null, 2)}`, { guildId, requestId })
logger.debug(`Last message: ${JSON.stringify(lastMessage, null, 2)}`, { guildId: guildId, requestId }) logger.debug(`Last message: ${JSON.stringify(lastMessage, null, 2)}`, { guildId, requestId })
const votes = await (await getVotesByEmote(lastMessage, guildId, requestId)) const votes = await (await getVotesByEmote(lastMessage, guildId, requestId))
.sort((a, b) => b.count - a.count) .sort((a, b) => b.count - a.count)
logger.debug(`votes: ${JSON.stringify(votes, null, 2)}`, { guildId: guildId, requestId }) logger.debug(`votes: ${JSON.stringify(votes, null, 2)}`, { guildId, requestId })
updateEvent(votes, guild!, guildId, requestId) updateEvent(votes, guild!, guildId, requestId)
updateMessage(votes[0].movie, lastMessage, guildId, requestId) updateMessage(votes[0].movie, lastMessage, guildId, requestId)
@ -67,20 +67,20 @@ async function updateMessage(movie: string, message: Message, guildId: string, r
const options: MessageEditOptions = { const options: MessageEditOptions = {
content: body, content: body,
} }
logger.info("Updating message.", {guildId: guildId, requestId}) logger.info("Updating message.", { guildId, requestId })
message.edit(options) message.edit(options)
} }
async function updateEvent(votes: Vote[], guild: Guild, guildId: string, requestId: string) { async function updateEvent(votes: Vote[], guild: Guild, guildId: string, requestId: string) {
logger.info(`Updating event with movie ${votes[0].movie}.`, { guildId: guildId, requestId }) logger.info(`Updating event with movie ${votes[0].movie}.`, { guildId, requestId })
const voteEvents = (await guild.scheduledEvents.fetch()) const voteEvents = (await guild.scheduledEvents.fetch())
.map((value, _) => value) .map((value, _) => value)
.filter(event => event.name.toLowerCase().includes("voting offen")) .filter(event => event.name.toLowerCase().includes("voting offen"))
logger.debug(`Found events: ${JSON.stringify(voteEvents, null, 2)}`, { guildId: guildId, requestId }) logger.debug(`Found events: ${JSON.stringify(voteEvents, null, 2)}`, { guildId, requestId })
if (!voteEvents || voteEvents.length <= 0) { if (!voteEvents || voteEvents.length <= 0) {
logger.error("Could not find vote event. Cancelling update!", { guildId: guildId, requestId }) logger.error("Could not find vote event. Cancelling update!", { guildId, requestId })
return return
} }
@ -89,8 +89,8 @@ async function updateEvent(votes: Vote[], guild: Guild, guildId: string, request
name: votes[0].movie, name: votes[0].movie,
description: `!wp\nNummer 2: ${votes[1].movie} mit ${votes[1].count - 1} Stimmen\nNummer 3: ${votes[2].movie} mit ${votes[2].count - 1} Stimmen` 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.debug(`Updating event: ${JSON.stringify(voteEvent, null, 2)}`, { guildId, requestId })
logger.info("Updating event.", {guildId: guildId, requestId}) logger.info("Updating event.", { guildId, requestId })
voteEvent.edit(options) voteEvent.edit(options)
} }
@ -102,12 +102,12 @@ type Vote = {
async function getVotesByEmote(message: Message, guildId: string, requestId: string): Promise<Vote[]> { async function getVotesByEmote(message: Message, guildId: string, requestId: string): Promise<Vote[]> {
const votes: Vote[] = [] const votes: Vote[] = []
logger.debug(`Number of items in emotes: ${Object.values(Emotes).length}`, {guildId: guildId, requestId}) logger.debug(`Number of items in emotes: ${Object.values(Emotes).length}`, { guildId, requestId })
for (let i = 0; i < Object.keys(Emotes).length / 2; i++) { for (let i = 0; i < Object.keys(Emotes).length / 2; i++) {
const emote = Emotes[i] const emote = Emotes[i]
logger.debug(`Getting reaction for emote ${emote}`, { guildId: guildId, requestId }) logger.debug(`Getting reaction for emote ${emote}`, { guildId, requestId })
const reaction = await message.reactions.resolve(emote) const reaction = await message.reactions.resolve(emote)
logger.debug(`Reaction for emote ${emote}: ${JSON.stringify(reaction, null, 2)}`, { guildId: guildId, requestId }) logger.debug(`Reaction for emote ${emote}: ${JSON.stringify(reaction, null, 2)}`, { guildId, requestId })
if (reaction) { if (reaction) {
const vote: Vote = { emote: emote, count: reaction.count, movie: extractMovieFromMessageByEmote(message, emote, guildId, requestId) } const vote: Vote = { emote: emote, count: reaction.count, movie: extractMovieFromMessageByEmote(message, emote, guildId, requestId) }
votes.push(vote) votes.push(vote)

View File

@ -47,6 +47,6 @@ async function createJFUsers(members: GuildMember[], movieName: string, requestI
} }
async function deleteJFUsers(guildId: string, requestId?: string) { async function deleteJFUsers(guildId: string, requestId?: string) {
logger.info(`Watchparty ended, deleting tmp users`) logger.info(`Watchparty ended, deleting tmp users`, { guildId, requestId })
jellyfinHandler.purge(guildId, requestId) jellyfinHandler.purge(guildId, requestId)
} }

View File

@ -230,7 +230,7 @@ export class JellyfinHandler {
} }
public async getAllMovies(guildId: string, requestId: string): Promise<BaseItemDto[]> { public async getAllMovies(guildId: string, requestId: string): Promise<BaseItemDto[]> {
logger.info("requesting all movies from jellyfin", { guildId: guildId, requestId }) logger.info("requesting all movies from jellyfin", { guildId, requestId })
const liloJfUser = await this.getUser(<GuildMember>{ guild: { id: guildId }, displayName: "lilo" }, requestId) const liloJfUser = await this.getUser(<GuildMember>{ guild: { id: guildId }, displayName: "lilo" }, requestId)
@ -240,15 +240,15 @@ export class JellyfinHandler {
} }
const movies = (await (this.moviesApi.getItems(searchParams))).items?.filter(item => !item.isFolder) const movies = (await (this.moviesApi.getItems(searchParams))).items?.filter(item => !item.isFolder)
// logger.debug(JSON.stringify(movies, null, 2), { guildId: guildId, requestId }) // logger.debug(JSON.stringify(movies, null, 2), { guildId: guildId, requestId })
logger.info(`Found ${movies?.length} movies in total`, { guildId: guildId, requestId }) logger.info(`Found ${movies?.length} movies in total`, { guildId, requestId })
return movies ?? [] return movies ?? []
} }
public async getRandomMovies(count: number, guildId: string, requestId: string): Promise<BaseItemDto[]> { public async getRandomMovies(count: number, guildId: string, requestId: string): Promise<BaseItemDto[]> {
logger.info(`${count} random movies requested.`, { guildId: guildId, requestId }) logger.info(`${count} random movies requested.`, { guildId, requestId })
const allMovies = await this.getAllMovies(guildId, requestId) const allMovies = await this.getAllMovies(guildId, requestId)
if (count >= allMovies.length) { if (count >= allMovies.length) {
logger.info(`${count} random movies requested but found only ${allMovies.length}. Returning all Movies.`, { guildId: guildId, requestId }) logger.info(`${count} random movies requested but found only ${allMovies.length}. Returning all Movies.`, { guildId, requestId })
return allMovies return allMovies
} }
const movies: BaseItemDto[] = [] const movies: BaseItemDto[] = []