All files / classes Event.ts

100% Statements 19/19
100% Branches 5/5
100% Functions 4/4
100% Lines 19/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 208x 8x 8x 8x 8x 8x 8x 8x 8x 1x 73x 73x 1x 1x 73x 73x 73x 73x 1x  
import type { ClientEvents } from "discord.js"
 
export type EventOptions<TEventName extends keyof ClientEvents> = {
  name: TEventName
  once?: boolean
  execute: (...args: ClientEvents[TEventName]) => Promise<void> | void
}
 
export class Event<TEventName extends keyof ClientEvents = keyof ClientEvents> {
  public readonly name: TEventName
  public readonly once: boolean
  public readonly execute: EventOptions<TEventName>["execute"]
 
  public constructor(options: EventOptions<TEventName>) {
    this.name = options.name
    this.once = options.once ?? false
    this.execute = options.execute
  }
}