mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-23 18:21:55 +01:00
🥅 Add logger for command execution exception filter
This commit is contained in:
parent
1dae9a8644
commit
cadb67e291
@ -4,6 +4,7 @@ import {
|
|||||||
DiscordExceptionFilter,
|
DiscordExceptionFilter,
|
||||||
On,
|
On,
|
||||||
} from '@discord-nestjs/core';
|
} from '@discord-nestjs/core';
|
||||||
|
import { Logger } from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
@ -18,20 +19,24 @@ import { Constants } from '../utils/constants';
|
|||||||
|
|
||||||
@Catch(Error)
|
@Catch(Error)
|
||||||
export class CommandExecutionError implements DiscordExceptionFilter {
|
export class CommandExecutionError implements DiscordExceptionFilter {
|
||||||
|
private readonly logger = new Logger(CommandExecutionError.name);
|
||||||
|
|
||||||
constructor(private readonly discordMessageService: DiscordMessageService) {}
|
constructor(private readonly discordMessageService: DiscordMessageService) {}
|
||||||
|
|
||||||
async catch(
|
async catch(
|
||||||
exception: Error,
|
exception: Error,
|
||||||
metadata: DiscordArgumentMetadata<string, any>,
|
metadata: DiscordArgumentMetadata<string, any>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
console.log(metadata);
|
|
||||||
const interaction: CommandInteraction = metadata.eventArgs[0];
|
const interaction: CommandInteraction = metadata.eventArgs[0];
|
||||||
|
|
||||||
if (!interaction.isCommand()) {
|
if (!interaction.isCommand()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(exception);
|
this.logger.error(
|
||||||
|
`Exception catched during the execution of command '${interaction.commandName}': ${exception.message}`,
|
||||||
|
exception.stack,
|
||||||
|
);
|
||||||
|
|
||||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
|
Loading…
Reference in New Issue
Block a user