owobot/util/commands.js

29 lines
814 B
JavaScript
Raw Normal View History

2024-08-12 05:13:32 -04:00
const fs = require('fs')
const cmds = Object.create(null)
const bpl = fs.readdirSync('./commands')
for (const plugin of bpl) {
if (!plugin.endsWith('.js')) {
2024-08-12 05:13:32 -04:00
continue
}
try {
const commandName = plugin.split('.js')[0]
cmds[commandName] = require(`../commands/${plugin}`)
2024-08-12 05:13:32 -04:00
if (cmds[commandName].level === undefined) {
cmds[commandName].level = 0
}
if (cmds[commandName].aliases) {
for (const alias of cmds[commandName].aliases) {
cmds[alias] = {
2024-08-12 05:13:32 -04:00
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) }
}
module.exports = cmds