Commit dead5522 authored by insert's avatar insert

Added a warning when module loading fails.

parent 2cdd25fd
......@@ -52,26 +52,30 @@ core.reload = () => {
let mods = fs.readdirSync('./core');
mods.forEach(mod => {
if (mod == 'index.js') return;
let path = `./core/${mod}/`;
let cmds = fs.readdirSync(path);
let i = index(path);
modules[mod] = i;
cmds.forEach(cmd => {
if (cmd == 'index.js' || cmd == 'lib') return;
if (cmd in i.disabled) return;
let a = (path + cmd).replace(/core\//g, '');
nrc(a);
let m = require(a);
let n = cmd.split('.').shift();
if (commands[n]) console.log('[WARN] A conflict has been detected, command ' + n + ' already exists! And ' + mod + ' is now overwriting it!');
let util = require('util');
if (!i.commands[n]) i.commands[n] = {};
commands[n] = Object.assign({
func: m,
desc: 'No description!',
req: 0
}, i.commands[n]);
});
try {
let path = `./core/${mod}/`;
let cmds = fs.readdirSync(path);
let i = index(path);
modules[mod] = i;
cmds.forEach(cmd => {
if (cmd == 'index.js' || cmd == 'lib') return;
if (cmd in i.disabled) return;
let a = (path + cmd).replace(/core\//g, '');
nrc(a);
let m = require(a);
let n = cmd.split('.').shift();
if (commands[n]) console.log('[WARN] A conflict has been detected, command ' + n + ' already exists! And ' + mod + ' is now overwriting it!');
let util = require('util');
if (!i.commands[n]) i.commands[n] = {};
commands[n] = Object.assign({
func: m,
desc: 'No description!',
req: 0
}, i.commands[n]);
});
} catch (e) {
console.error('[WARN] Failed to load module, ' + mod + '!');
}
});
};
......
This diff is collapsed.
......@@ -19,6 +19,7 @@
],
"dependencies": {
"discord.js": "^11.3.2",
"node-opus": "^0.3.0"
"node-opus": "^0.3.0",
"request": "^2.87.0"
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment