Feature/103 improve events (#201)

* Improve event handler to only run events that have been registered

* Tidy up events into their own function files
This commit is contained in:
Vylpes 2022-10-09 15:23:25 +01:00 committed by GitHub
parent ed8f5927c8
commit 0d63bd120d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 361 additions and 379 deletions

View file

@ -1,10 +1,10 @@
import { Client } from "discord.js";
import * as dotenv from "dotenv";
import { createConnection } from "typeorm";
import { EventType } from "../constants/EventType";
import ICommandItem from "../contracts/ICommandItem";
import IEventItem from "../contracts/IEventItem";
import { Command } from "../type/command";
import { Event } from "../type/event";
import { Events } from "./events";
import { Util } from "./util";
@ -65,9 +65,10 @@ export class CoreClient extends Client {
CoreClient._commandItems.push(item);
}
public static RegisterEvent(event: Event) {
public static RegisterEvent(eventType: EventType, func: Function) {
const item: IEventItem = {
Event: event,
EventType: eventType,
ExecutionFunction: func,
};
CoreClient._eventItems.push(item);