add game command

This commit is contained in:
Tutur33
2024-02-26 11:20:08 +01:00
parent a9d92fbff6
commit 7ee772a6b9
23 changed files with 229 additions and 160 deletions
+2 -5
View File
@@ -1,25 +1,22 @@
import fs from 'fs';
import path from 'path';
module.exports = function loadEvents(client: any, dir: string) {
module.exports = function loadCommands(client: any, dir: string) {
let count = 0;
dir = `../${dir}`
fs.readdirSync(path.join(__dirname, dir)).forEach((file: string) => {
const filePath = path.join(__dirname, dir, file);
if (fs.statSync(filePath).isDirectory()) {
count += loadCommands(path.join(dir, file));
count += loadCommands(client, path.join(dir, file));
} else if (file.endsWith('.js') || file.endsWith('.ts')) {
try {
delete require.cache[require.resolve(filePath)];
const command = require(filePath);
const fileName = file.replace(/\.js|\.ts/g, '');
command.name = fileName;
console.log(command);
if (!command.category) {
const parentDir = path.basename(path.dirname(filePath));
command.category = parentDir === 'commands' ? 'other' : parentDir;
}
console.log(command);
client.commands.set(fileName, command);
if (command.aliases) {
command.aliases.forEach((alias: string) => {