Only load scripts and modules that end in .js

This commit is contained in:
chris062689 2017-03-25 21:33:44 -04:00
parent e36ac7257a
commit 02ec9079ff

View File

@ -21,12 +21,18 @@ client.on('ready', () => {
// Cache all command modules. // Cache all command modules.
require("fs").readdirSync('./commands/').forEach(function(file) { require("fs").readdirSync('./commands/').forEach(function(file) {
// Load the module if it's a script.
if (path.extname(file) == '.js') {
cachedModules[file] = require(`./commands/${file}`); cachedModules[file] = require(`./commands/${file}`);
}
}); });
// Cache all triggers. // Cache all triggers.
require("fs").readdirSync('./triggers/').forEach(function(file) { require("fs").readdirSync('./triggers/').forEach(function(file) {
// Load the trigger if it's a script.
if (path.extname(file) == '.js') {
cachedTriggers.push(require(`./triggers/${file}`)); cachedTriggers.push(require(`./triggers/${file}`));
}
}); });
// Initalize app channels. // Initalize app channels.