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