refactor: replace console.* with logger in core lib files

Update loaders, handlers, and BotClient to use centralized logger:
- CommandLoader.ts and EventLoader.ts
- AutocompleteHandler.ts, CommandHandler.ts, ComponentInteractionHandler.ts
- BotClient.ts

Provides consistent formatting across all core library logging.
This commit is contained in:
syntaxbullet
2025-12-24 21:56:50 +01:00
parent a53d30a0b3
commit 10a760edf4
6 changed files with 34 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ import type { Command } from "@lib/types";
import { config } from "@lib/config";
import type { LoadResult, LoadError } from "./types";
import type { Client } from "../BotClient";
import { logger } from "@lib/logger";
/**
* Handles loading commands from the file system
@@ -44,7 +45,7 @@ export class CommandLoader {
await this.loadCommandFile(filePath, reload, result);
}
} catch (error) {
console.error(`Error reading directory ${dir}:`, error);
logger.error(`Error reading directory ${dir}:`, error);
result.errors.push({ file: dir, error });
}
}
@@ -59,7 +60,7 @@ export class CommandLoader {
const commands = Object.values(commandModule);
if (commands.length === 0) {
console.warn(`⚠️ No commands found in ${filePath}`);
logger.warn(`No commands found in ${filePath}`);
result.skipped++;
return;
}
@@ -73,21 +74,21 @@ export class CommandLoader {
const isEnabled = config.commands[command.data.name] !== false;
if (!isEnabled) {
console.log(`🚫 Skipping disabled command: ${command.data.name}`);
logger.info(`🚫 Skipping disabled command: ${command.data.name}`);
result.skipped++;
continue;
}
this.client.commands.set(command.data.name, command);
console.log(`Loaded command: ${command.data.name}`);
logger.success(`Loaded command: ${command.data.name}`);
result.loaded++;
} else {
console.warn(`⚠️ Skipping invalid command in ${filePath}`);
logger.warn(`Skipping invalid command in ${filePath}`);
result.skipped++;
}
}
} catch (error) {
console.error(`Failed to load command from ${filePath}:`, error);
logger.error(`Failed to load command from ${filePath}:`, error);
result.errors.push({ file: filePath, error });
}
}