From cadb67e291bc8b0fe5390d5bf1e8500d27a1460a Mon Sep 17 00:00:00 2001 From: Manuel Ruwe Date: Mon, 19 Dec 2022 09:52:30 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Add=20logger=20for=20command=20e?= =?UTF-8?q?xecution=20exception=20filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/middleware/command-execution-filter.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/middleware/command-execution-filter.ts b/src/middleware/command-execution-filter.ts index 908ee73..f15e5c8 100644 --- a/src/middleware/command-execution-filter.ts +++ b/src/middleware/command-execution-filter.ts @@ -4,6 +4,7 @@ import { DiscordExceptionFilter, On, } from '@discord-nestjs/core'; +import { Logger } from '@nestjs/common'; import { ActionRowBuilder, ButtonBuilder, @@ -18,20 +19,24 @@ import { Constants } from '../utils/constants'; @Catch(Error) export class CommandExecutionError implements DiscordExceptionFilter { + private readonly logger = new Logger(CommandExecutionError.name); + constructor(private readonly discordMessageService: DiscordMessageService) {} async catch( exception: Error, metadata: DiscordArgumentMetadata, ): Promise { - console.log(metadata); const interaction: CommandInteraction = metadata.eventArgs[0]; if (!interaction.isCommand()) { return; } - console.log(exception); + this.logger.error( + `Exception catched during the execution of command '${interaction.commandName}': ${exception.message}`, + exception.stack, + ); const row = new ActionRowBuilder().addComponents( new ButtonBuilder()