refactor(events/interaction): now using the new log system

This commit is contained in:
Raphael 2025-10-26 17:39:48 +01:00 committed by Raphaël
parent 7d76366893
commit 6c3a7587e8

View file

@ -1,18 +1,24 @@
import { CommandInteraction, Events, Interaction, MessageFlags } from 'discord.js';
import {
CommandInteraction,
Events,
Interaction,
MessageFlags,
} from 'discord.js';
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
import { log } from '@lib/log';
export default {
name: Events.InteractionCreate,
async execute(interaction: Interaction) {
if (!interaction.isChatInputCommand()) return;
const command: CommandInteraction = interaction.client.commands.get(interaction.commandName);
const command: CommandInteraction = interaction.client.commands.get(
interaction.commandName,
);
try {
await command.execute(interaction);
}
catch (err) {
console.error(
`⚠️ | Error when occured this command ${interaction.commandName}\n\t${err as Error}`,
);
log.error(err, `Error when occured this command ${interaction.commandName}`);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({
content: `${emoji.answer.error} | ${interaction.commandName} seems have a problem, thanks report that to the support (After Print)`,