chomens-bot-js/util/load_files.js
2022-11-08 17:43:24 +07:00

20 lines
389 B
JavaScript

const fs = require('fs');
const path = require('path');
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;