Add card setup function to bot setup

This commit is contained in:
Ethan Lane 2023-09-03 17:34:03 +01:00
parent 51d97bacd5
commit d85e5a1eb2
2 changed files with 10 additions and 5 deletions

View file

@ -5,7 +5,7 @@ import Series from "../database/entities/card/Series";
import path from "path";
import { CardRarity } from "../constants/CardRarity";
export default class CardSetupFunctions {
export default class CardSetupFunction {
public async Execute() {
await this.ClearDatabase();
await this.ReadSeries();

View file

@ -7,7 +7,8 @@ import { Command } from "../type/command";
import { Events } from "./events";
import { Util } from "./util";
import AppDataSource from "../database/dataSources/appDataSource";
import CardSetupFunction from "../Functions/CardSetupFunction";
import CardDataSource from "../database/dataSources/cardDataSource";
export class CoreClient extends Client {
private static _commandItems: ICommandItem[];
@ -15,6 +16,7 @@ export class CoreClient extends Client {
private _events: Events;
private _util: Util;
private _cardSetupFunc: CardSetupFunction;
public static get commandItems(): ICommandItem[] {
return this._commandItems;
@ -33,6 +35,7 @@ export class CoreClient extends Client {
this._events = new Events();
this._util = new Util();
this._cardSetupFunc = new CardSetupFunction();
}
public async start() {
@ -41,13 +44,15 @@ export class CoreClient extends Client {
return;
}
await AppDataSource.initialize()
.then(() => console.log("Data Source Initialized"))
.catch((err) => console.error("Error Initialising Data Source", err));
await CardDataSource.initialize()
.then(() => console.log("Card Data Source Initialised"))
.catch(err => console.error("Error initialising Card Data Source", err));
super.on("interactionCreate", this._events.onInteractionCreate);
super.on("ready", this._events.onReady);
await this._cardSetupFunc.Execute();
await super.login(process.env.BOT_TOKEN);
this._util.loadEvents(this, CoreClient._eventItems);