botv12/util/commands.js
2024-10-26 13:32:34 -04:00

30 lines
864 B
JavaScript

const cmds = Object.create(null)
import { readdirSync } from "node:fs"
const bpl = readdirSync('commands')
for (const plugin of bpl) {
if (!plugin.endsWith('.js')) {
continue
}
try {
const commandName = plugin.split('.js')[0]
import(`../commands/${plugin}`).then((pluginItem)=>{
cmds[commandName] = pluginItem // For rejoining
if (cmds[commandName].aliases) {
for (const j in cmds[commandName].aliases) {
cmds[cmds[commandName].aliases[j]] = {
execute: cmds[commandName].execute,
alias: commandName,
usage: cmds[commandName].usage,
level: cmds[commandName].level,
hidden: true,
consoleIndex: cmds[commandName].consoleIndex
}
}
}
})
} catch (e) { console.log(e) }
}
export default cmds