feat: implement db
This commit is contained in:
+17
-10
@@ -11,6 +11,7 @@ import {
|
||||
import { Logger } from './utils/log';
|
||||
import { config } from './utils/config';
|
||||
import { CommandManager } from './commands';
|
||||
import { DatabaseManager } from './modules/db';
|
||||
|
||||
type BotEventListeners = {
|
||||
messageCreate: (message: Message) => void;
|
||||
@@ -30,8 +31,8 @@ export class Bot {
|
||||
} = {};
|
||||
|
||||
/*
|
||||
class methods
|
||||
*/
|
||||
class methods
|
||||
*/
|
||||
private constructor() {
|
||||
this.log = new Logger('Bot');
|
||||
this.cmdMgr = new CommandManager('./commands');
|
||||
@@ -46,6 +47,12 @@ export class Bot {
|
||||
this.log.info('Loading commands');
|
||||
await this.cmdMgr.init();
|
||||
|
||||
this.log.info('Configuring database');
|
||||
DatabaseManager.get.init(
|
||||
this.cmdMgr.getUserKeys(),
|
||||
this.cmdMgr.getGuildKeys()
|
||||
);
|
||||
|
||||
this.log.info('Instantiating client');
|
||||
this.client = new Client({
|
||||
intents: [
|
||||
@@ -77,8 +84,8 @@ export class Bot {
|
||||
}
|
||||
|
||||
/*
|
||||
event listeners
|
||||
*/
|
||||
event listeners
|
||||
*/
|
||||
private onReady(): void {
|
||||
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> {
|
||||
this.emit('interactionCreate', interaction);
|
||||
}
|
||||
@@ -138,8 +145,8 @@ export class Bot {
|
||||
}
|
||||
|
||||
/*
|
||||
registerable event system
|
||||
*/
|
||||
registerable event system
|
||||
*/
|
||||
public on<K extends keyof BotEventListeners>(
|
||||
event: K,
|
||||
listener: BotEventListener<K>
|
||||
@@ -197,8 +204,8 @@ export class Bot {
|
||||
}
|
||||
|
||||
/*
|
||||
singleton logic
|
||||
*/
|
||||
singleton logic
|
||||
*/
|
||||
static #instance: Bot | null = null;
|
||||
|
||||
public static get get(): Bot {
|
||||
|
||||
Reference in New Issue
Block a user