feat: improve component and command loading functions with directory existence checks

This commit is contained in:
2025-09-27 16:05:40 -05:00
parent db44e148d3
commit 05e83b5e14
3 changed files with 24 additions and 4 deletions

View File

@@ -2,7 +2,13 @@ import { bot } from "../../main";
import path from "node:path";
import * as fs from "node:fs";
export function loadEvents(dir: string = path.join(__dirname, "../events")) {
export function loadEvents(dir: string = path.resolve(__dirname, "../../events")) {
// Evitar fallo si el directorio no existe
if (!fs.existsSync(dir)) {
console.warn(`⚠️ Directorio de eventos no encontrado: ${dir}`);
return;
}
const files = fs.readdirSync(dir);
for (const file of files) {