add anti crash + command

This commit is contained in:
Tutur33
2024-03-15 20:35:35 +01:00
parent deac21bd8e
commit 51e2d61358
14 changed files with 208 additions and 46 deletions
+2 -1
View File
@@ -12,11 +12,12 @@ module.exports = function loadCommands(client: any, dir: string) {
delete require.cache[require.resolve(filePath)];
const command = require(filePath);
const fileName = file.replace(/\.js|\.ts/g, '');
command.name = fileName;
if (!command.name) command.name = fileName;
if (!command.category) {
const parentDir = path.basename(path.dirname(filePath));
command.category = parentDir === 'commands' ? 'other' : parentDir;
}
if (!command.permission) command.permission = 0;
client.commands.set(fileName, command);
if (command.aliases) {
command.aliases.forEach((alias: string) => {