-
Notifications
You must be signed in to change notification settings - Fork 13
/
Event.ts
50 lines (45 loc) · 1.16 KB
/
Event.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Client } from '../client/Client';
/**
* Method to be implemented that will be executed whenever the event this handler
* is for is emitted by the Client
* @abstact
* @method Event#action
* @param {any[]} ...args - The args your event handler will be receiving
* from the event it handles. This can be any number
* of arguments and obviously they can be received
* individually or as a rest parameter without issue
* @returns {void}
*/
/**
* Event class to extend when writing your own custom event handlers
* @abstract
* @param {string} name - Name of the Client event this event handler
* will handle when emitted
*/
export abstract class Event<T extends Client = Client>
{
public name: string;
public client!: T;
public constructor(name: string)
{
/**
* The name of the event this Event handler handles
* @type {string}
*/
this.name = name;
}
/**
* Receive the client instance and save it
* @private
*/
public register(client: T): void
{
/**
* The YAMDBF Client instance
* @type {Client}
*/
this.client = client;
}
// Docs above class
public abstract action(...args: any[]): void;
}