mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-27 09:35:35 -05:00
25 lines
537 B
JavaScript
25 lines
537 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
/**
|
|
* loads js files
|
|
* @param {string} directory the directory that contains the js files
|
|
* @return {Array} an array of require()ed js files
|
|
*/
|
|
function loadPlugins(directory) {
|
|
const plugins = [];
|
|
|
|
for (const filename of fs.readdirSync(directory)) {
|
|
if (!filename.endsWith('.js')) continue;
|
|
|
|
const filepath = path.join(directory, filename);
|
|
|
|
const plugin = require(filepath);
|
|
|
|
plugins.push(plugin);
|
|
}
|
|
|
|
return plugins;
|
|
}
|
|
|
|
module.exports = loadPlugins;
|