25 lines
654 B
TypeScript
25 lines
654 B
TypeScript
/**
|
|
* Event types and interfaces
|
|
*/
|
|
|
|
import type { ClientEvents } from "discord.js";
|
|
import type { BotClient } from "../core/client";
|
|
|
|
export interface EventHandler<K extends keyof ClientEvents = keyof ClientEvents> {
|
|
/** Event name to listen for */
|
|
name: K;
|
|
|
|
/** Whether to only run once */
|
|
once?: boolean;
|
|
|
|
/** Execute the event handler */
|
|
execute: (client: BotClient, ...args: ClientEvents[K]) => Promise<void> | void;
|
|
}
|
|
|
|
// Type-safe event handler that can be stored in an array
|
|
export type AnyEventHandler = {
|
|
name: keyof ClientEvents;
|
|
once?: boolean;
|
|
execute: (client: BotClient, ...args: any[]) => Promise<void> | void;
|
|
};
|