Fixed some stuff

This commit is contained in:
Vylpes 2020-10-23 19:13:05 +01:00
parent 0a55a1dbae
commit 160b306439

View file

@ -9,14 +9,14 @@ class util {
loadCommand(name, args, message) { loadCommand(name, args, message) {
for (let c = 0; c < this._client.config.commands.length; c++) { for (let c = 0; c < this._client.config.commands.length; c++) {
let folder = this._client.config.commands[c]; let folder = this._client.config.commands[c];
stat(`${process.cwd()}/${this._client.config.commands}/${name}.js`, (err, stat) => { stat(`${process.cwd()}/${folder}/${name}.js`, (err, stat) => {
if (err == null) { if (err == null) {
let commandFile = require(`${process.cwd()}/${this._client.config.commands}/${name}.js`); let commandFile = require(`${process.cwd()}/${this._client.config.commands}/${name}.js`);
let command = new commandFile(); let command = new commandFile();
let requiredConfigs = command.requiredConfigs; let requiredConfigs = command.requiredConfigs;
for (let i = 0; i < requiredConfigs.length; i++) { for (let i = 0; i < requiredConfigs.length; i++) {
if (!this._client.config[name]) throw `${commandFile.name} requires ${requiredConfigs[i]} in it's configuration`; if (!this._client.config[name]) throw `${commandFile.name} requires ${requiredConfigs[i]} in it's configuration`;
if (!this._client.config[name][requiredConfigs[i]]) throw `${commandFile.name} requires ${requiredConfigs[i]} in it's configuration`; if (!this._client.config[name][requiredConfigs[i]]) throw `${commandFile.name} requires ${requiredConfigs[i]} in it's configuration`;
@ -30,7 +30,7 @@ class util {
return; return;
} }
} }
command[command.run]({ command[command.run]({
"command": name, "command": name,
"arguments": args, "arguments": args,
@ -46,15 +46,19 @@ class util {
} }
loadEvents() { loadEvents() {
let eventFiles = readdirSync(`${process.cwd()}/${this._client.config.events}/`); for (let e = 0; e < this._config.events.length; e++) {
let folder = this._config.events[e];
for (let i = 0; i < eventFiles.length; i++) { let eventFiles = readdirSync(`${process.cwd()}/${folder}/`);
let eventName = eventFiles[i].split('.')[0];
let file = require(`${process.cwd()}/${this._client.config.events}/${eventName}.js`); for (let i = 0; i < eventFiles.length; i++) {
let eventName = eventFiles[i].split('.')[0];
let event = new file; let file = require(`${process.cwd()}/${this._client.config.events}/${eventName}.js`);
this._client.on(eventName, event[event.run]); let event = new file;
this._client.on(eventName, event[event.run]);
}
} }
} }
} }