feat: use cmd manager
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { Logger } from './utils/log';
|
import { Logger } from './utils/log';
|
||||||
import { config } from './utils/config';
|
import { config } from './utils/config';
|
||||||
|
import { CommandManager } from './commands';
|
||||||
|
|
||||||
type BotEventListeners = {
|
type BotEventListeners = {
|
||||||
messageCreate: (message: Message) => void;
|
messageCreate: (message: Message) => void;
|
||||||
@@ -23,6 +24,7 @@ export class Bot {
|
|||||||
|
|
||||||
private readonly token: string;
|
private readonly token: string;
|
||||||
private readonly clientId: string;
|
private readonly clientId: string;
|
||||||
|
private cmdMgr: CommandManager;
|
||||||
|
|
||||||
private readonly log: Logger;
|
private readonly log: Logger;
|
||||||
|
|
||||||
@@ -38,6 +40,7 @@ export class Bot {
|
|||||||
|
|
||||||
this.token = config.token;
|
this.token = config.token;
|
||||||
this.clientId = config.client_id;
|
this.clientId = config.client_id;
|
||||||
|
this.cmdMgr = new CommandManager('./commands');
|
||||||
}
|
}
|
||||||
|
|
||||||
public async init(): Promise<void> {
|
public async init(): Promise<void> {
|
||||||
@@ -46,6 +49,9 @@ export class Bot {
|
|||||||
if (this.client)
|
if (this.client)
|
||||||
throw new Error('Client already exists, was init called twice?');
|
throw new Error('Client already exists, was init called twice?');
|
||||||
|
|
||||||
|
this.log.info('Loading commands');
|
||||||
|
await this.cmdMgr.init();
|
||||||
|
|
||||||
this.log.info('Instantiating client');
|
this.log.info('Instantiating client');
|
||||||
this.client = new Client({
|
this.client = new Client({
|
||||||
intents: [
|
intents: [
|
||||||
|
|||||||
Reference in New Issue
Block a user