refactor: added debug in many loading func

This commit is contained in:
Slincnik 2025-01-14 23:50:48 +03:00
parent cc10969ccf
commit a0309c164a
No known key found for this signature in database
4 changed files with 10 additions and 1 deletions

View file

@ -37,6 +37,7 @@ const registerGlobalCommands = async (client: ExtendedClient, commands: CommandF
logger.log(`Edited command globally: ${data.name}`); logger.log(`Edited command globally: ${data.name}`);
} else if (!targetCommand) { } else if (!targetCommand) {
await appCommandsManager.create(data).catch(() => logger.error(`Failed to register command: ${data.name}`)); await appCommandsManager.create(data).catch(() => logger.error(`Failed to register command: ${data.name}`));
logger.debug(`Command ${data.name} loaded globally`);
} }
}), }),
); );
@ -77,6 +78,7 @@ const registerDevCommands = async (client: ExtendedClient, commands: CommandFile
logger.log(`Edited command globally: ${data.name}`); logger.log(`Edited command globally: ${data.name}`);
} else if (!targetCommand) { } else if (!targetCommand) {
await guildCommands.create(data).catch(() => logger.error(`Failed to register command: ${data.name} in ${guildCommands.guild.name} server`)); await guildCommands.create(data).catch(() => logger.error(`Failed to register command: ${data.name} in ${guildCommands.guild.name} server`));
logger.debug(`Command ${data.name} loaded in dev`);
} }
}); });
}), }),

View file

@ -94,7 +94,7 @@ export class CommandHandler {
interaction, interaction,
}); });
} catch (error) { } catch (error) {
logger.error(error); logger.error(error, "Command cannot be executed");
} }
}); });
} }

View file

@ -53,6 +53,8 @@ export class EventHandler {
} }
this.events.push({ data, run }); this.events.push({ data, run });
logger.debug(`Event ${eventFilePath} loaded`);
} }
} catch (error) { } catch (error) {
logger.error("Error build events: ", error); logger.error("Error build events: ", error);

View file

@ -1,3 +1,4 @@
import useClient from "@/utils/use-client.js";
import chalk from "chalk"; import chalk from "chalk";
function format(tDate: Date | number) { function format(tDate: Date | number) {
@ -34,6 +35,10 @@ export default {
}, },
debug(...content: unknown[]) { debug(...content: unknown[]) {
const client = useClient();
const isProd = client.configService.get("production");
console.log(isProd);
if (isProd) return;
return console.log(`[${format(Date.now())}]: ${logLevels.DEBUG} ${content.join(" ")}`); return console.log(`[${format(Date.now())}]: ${logLevels.DEBUG} ${content.join(" ")}`);
}, },