refactor: migrate bot handlers to centralized logger

This commit is contained in:
syntaxbullet
2026-01-14 17:58:28 +01:00
parent 54944283a3
commit 1e20a5a7a0
3 changed files with 10 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ import { ChatInputCommandInteraction, MessageFlags } from "discord.js";
import { AuroraClient } from "@/lib/BotClient";
import { userService } from "@shared/modules/user/user.service";
import { createErrorEmbed } from "@lib/embeds";
import { logger } from "@shared/lib/logger";
/**
@@ -13,7 +14,7 @@ export class CommandHandler {
const command = AuroraClient.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
logger.error("bot", `No command matching ${interaction.commandName} was found.`);
return;
}
@@ -28,14 +29,14 @@ export class CommandHandler {
try {
await userService.getOrCreateUser(interaction.user.id, interaction.user.username);
} catch (error) {
console.error("Failed to ensure user exists:", error);
logger.error("bot", "Failed to ensure user exists", error);
}
try {
await command.execute(interaction);
AuroraClient.lastCommandTimestamp = Date.now();
} catch (error) {
console.error(String(error));
logger.error("bot", `Error executing command ${interaction.commandName}`, error);
const errorEmbed = createErrorEmbed('There was an error while executing this command!');
if (interaction.replied || interaction.deferred) {