🏷️ added event type
This commit is contained in:
parent
2dffdfcb5b
commit
e6af84f702
2 changed files with 8 additions and 1 deletions
6
src/interfaces/Event.ts
Normal file
6
src/interfaces/Event.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { IEventOptions } from "./EventOptions";
|
||||
|
||||
export interface IEvent {
|
||||
options: IEventOptions;
|
||||
execute: (...args: any[]) => Promise<void>;
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue