dashboard-core/HandlerIntegration/index.js
Jonny_Bro (Nikita) 849a93887a
2023-06-22 19:36:52 +05:00

26 lines
No EOL
703 B
JavaScript

const prefix = "[DBD-Storage-Handler]";
const Keyv = require("keyv");
const { join } = require("path");
class Handler {
constructor(keyvAdapter) {
this.db = new Keyv(keyvAdapter || `sqlite://${join(__dirname, "/database.sqlite")}`);
this.db.on("error", (err) => console.error(`${prefix} ${`Keyv connection error: ${err}`.red}`));
this.Category = require(`${__dirname}/structures/Category`)(this.db);
this.Option = require(`${__dirname}/structures/Option`)(this.db);
console.log(`${prefix} Database successfully initialized!`);
}
async fetch(guildId, optionId) {
return await this.db.get(`${guildId}.options.${optionId}`);
}
db() {
return this.db;
}
}
module.exports = Handler;