galactic-bot/storage/StorageManager.js
2020-04-14 00:41:42 -06:00

38 lines
843 B
JavaScript

const { Collection } = require('../util/');
const path = require('path');
const fs = require('fs');
class StorageManager {
constructor(manager, options = {}) {
this.manager = manager;
this.providers = new Collection();
this.options = options;
}
async initialize() {
this.manager.logger.write('debug', "Initializing storage providers.");
let _providers = path.join(process.cwd(), 'storage', 'providers');
let providers = fs.readdirSync(_providers);
for(let _provider of providers) {
let provider = require(path.join(_providers, _provider));
provider = new provider(this.manager, this.options);
await provider.init();
this.providers.set(provider.name, provider);
}
}
}
module.exports = StorageManager;