owobot/util/commands.js

31 lines
937 B
JavaScript
Raw Normal View History

2024-08-12 05:13:32 -04:00
const fs = require('fs')
2024-09-19 22:21:01 -04:00
const settings = require('../settings.json')
2024-08-12 05:13:32 -04:00
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]
2024-09-19 22:21:01 -04:00
if (commandName === 'settings' && settings.userSettingsDisabled) continue
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