galactic-bot/storage/StorageManager.js

36 lines
815 B
JavaScript

const { Collection } = require('../util/');
const path = require('path');
const fs = require('fs');
class StorageManager {
constructor(manager, options = {}) {
this.providers = new Collection();
this.manager = manager;
this.options = options;
}
async initialize() {
console.log('Initiating 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;