galactic-bot/storage/StorageManager.js

36 lines
815 B
JavaScript
Raw Normal View History

2020-04-08 16:27:34 +02:00
const { Collection } = require('../util/');
2020-04-11 21:16:37 +02:00
const path = require('path');
const fs = require('fs');
2020-04-08 16:27:34 +02:00
class StorageManager {
2020-04-11 21:16:37 +02:00
constructor(manager, options = {}) {
2020-04-08 16:27:34 +02:00
this.providers = new Collection();
2020-04-11 21:16:37 +02:00
this.manager = manager;
this.options = options;
2020-04-08 16:27:34 +02:00
}
2020-04-09 16:30:52 +02:00
async initialize() {
2020-04-11 21:16:37 +02:00
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);
}
2020-04-09 16:30:52 +02:00
}
2020-04-08 16:27:34 +02:00
}
module.exports = StorageManager;