feat: implement db

This commit is contained in:
2026-01-13 18:36:54 -03:00
parent af7c25e6ec
commit 7d0b5dc459
+17 -10
View File
@@ -11,6 +11,7 @@ import {
import { Logger } from './utils/log'; import { Logger } from './utils/log';
import { config } from './utils/config'; import { config } from './utils/config';
import { CommandManager } from './commands'; import { CommandManager } from './commands';
import { DatabaseManager } from './modules/db';
type BotEventListeners = { type BotEventListeners = {
messageCreate: (message: Message) => void; messageCreate: (message: Message) => void;
@@ -30,8 +31,8 @@ export class Bot {
} = {}; } = {};
/* /*
class methods class methods
*/ */
private constructor() { private constructor() {
this.log = new Logger('Bot'); this.log = new Logger('Bot');
this.cmdMgr = new CommandManager('./commands'); this.cmdMgr = new CommandManager('./commands');
@@ -46,6 +47,12 @@ export class Bot {
this.log.info('Loading commands'); this.log.info('Loading commands');
await this.cmdMgr.init(); await this.cmdMgr.init();
this.log.info('Configuring database');
DatabaseManager.get.init(
this.cmdMgr.getUserKeys(),
this.cmdMgr.getGuildKeys()
);
this.log.info('Instantiating client'); this.log.info('Instantiating client');
this.client = new Client({ this.client = new Client({
intents: [ intents: [
@@ -77,8 +84,8 @@ export class Bot {
} }
/* /*
event listeners event listeners
*/ */
private onReady(): void { private onReady(): void {
this.log.info('Logged in'); this.log.info('Logged in');
@@ -120,8 +127,8 @@ export class Bot {
} }
/* /*
public event listeners public event listeners
*/ */
private async onInteraction(interaction: Interaction): Promise<void> { private async onInteraction(interaction: Interaction): Promise<void> {
this.emit('interactionCreate', interaction); this.emit('interactionCreate', interaction);
} }
@@ -138,8 +145,8 @@ export class Bot {
} }
/* /*
registerable event system registerable event system
*/ */
public on<K extends keyof BotEventListeners>( public on<K extends keyof BotEventListeners>(
event: K, event: K,
listener: BotEventListener<K> listener: BotEventListener<K>
@@ -197,8 +204,8 @@ export class Bot {
} }
/* /*
singleton logic singleton logic
*/ */
static #instance: Bot | null = null; static #instance: Bot | null = null;
public static get get(): Bot { public static get get(): Bot {