🏷️ added event type

This commit is contained in:
Axel Olausson Holtenäs 2022-05-30 17:31:34 +02:00
parent 2dffdfcb5b
commit e6af84f702
No known key found for this signature in database
GPG key ID: 7BF6826B76382CBA
2 changed files with 8 additions and 1 deletions

6
src/interfaces/Event.ts Normal file
View file

@ -0,0 +1,6 @@
import { IEventOptions } from "./EventOptions";
export interface IEvent {
options: IEventOptions;
execute: (...args: any[]) => Promise<void>;
}

View file

@ -1,13 +1,14 @@
/* eslint-disable no-loops/no-loops */
import { Client } from "discord.js";
import listDir from "../../helpers/listDir";
import { IEvent } from "../../interfaces/Event";
export const register = async (client: Client) => {
const eventNames = await listDir("events");
if (!eventNames) return;
for await (const eventName of eventNames) {
const event = await import(`../../events/${eventName}`);
const event: IEvent = await import(`../../events/${eventName}`);
const eventExecutor = async (...args: any[]) => event.execute(...args);
if (!event.options?.type) return;