This commit is contained in:
Flummi 2019-08-20 22:48:58 +00:00
parent d0821b3553
commit 19782dd6f8

View File

@ -18,12 +18,10 @@ export default class cuffeo extends EventEmitter {
})(); })();
} }
async loadLibs() { async loadLibs() {
const _libs = {}; return (await (Promise.all((await fs.promises.readdir(`${__dirname}/clients`)).filter(f => f.endsWith(".mjs")).map(async client => {
for (const client of (await fs.promises.readdir(`${__dirname}/clients`)).filter(f => f.endsWith(".mjs"))) { const lib = (await import(`./clients/${client}`)).default;
const lib = await import(`./clients/${client}`); return { [lib.name]: lib };
_libs[lib.default.name] = lib.default; })))).reduce((a, b) => ({ ...a, ...b }));
}
return _libs;
} }
async registerClients(cfg) { async registerClients(cfg) {
return cfg.filter(e => e.enabled).map(async srv => { return cfg.filter(e => e.enabled).map(async srv => {