v6.0.0-beta

This commit is contained in:
Parker2991
2024-08-09 22:08:42 -04:00
parent bca181e8ec
commit 0b31c50a29
28 changed files with 261058 additions and 185 deletions
+21 -1
View File
@@ -129,7 +129,9 @@ function command_manager (bot, options, config, discordClient) {
command.aliases.map((a) => (this.commands[a] = command));
}
},
unregister (command) {
this.commands = {}
},
getCommand (name) {
return this.commands[name]
},
@@ -169,5 +171,23 @@ function command_manager (bot, options, config, discordClient) {
}
})
})
bot.commandManager.reload = function () {
commandlist = [];
for (const filename of fs.readdirSync(path.join(__dirname, "../commands"))) {
try {
delete require.cache[require.resolve(path.join(__dirname, "../commands", filename))]
const command = require(path.join(__dirname, "../commands", filename));
// bot.commandManager.unregister(command);
// this.commands = {};
bot.commandManager.register(command);
bot.commandManager.commandlist.pop(command);
// bot.commandManager.register(command);
bot.commandManager.commandlist.push(command)
} catch (error) {
bot.console.error(["Failed to load File ", filename, ":", error.stack])
bot.tellraw("@a", { text: `Failed to reload file ${filename}\n${error.stack}`, color: "red" })
}
}
}
}
module.exports = command_manager;