Skip to content

Commit

Permalink
Fixing event listener overloads (#39)
Browse files Browse the repository at this point in the history
* fixing event listener overloads

* add dist folder test

* remove dist folder

* remove package.json

* Delete outdated TODO comment

Co-authored-by: George <georgej1088@gmail.com>
  • Loading branch information
Skillz4Killz and eritbh committed Jan 8, 2020
1 parent 3e3a3d0 commit b892b0b
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/Client.ts
Expand Up @@ -363,14 +363,13 @@ export class Client extends Eris.Client implements ClientOptions {
}
}

export declare interface Client extends Eris.Client {
on(event: string, listener: Function): this;
interface YuukoEvents<T> extends Eris.ClientEvents<T> {
/**
* @event
* Fired when a command is loaded.
* @param command The command that was loaded
*/
on(event: 'commandLoaded', listener: (cmd: Command) => void): this;
(event: 'commandLoaded', listener: (cmd: Command) => void): T;
/**
* @event
* Fired just before a command has its requirements evaluated on an
Expand All @@ -380,7 +379,7 @@ export declare interface Client extends Eris.Client {
* @param args The arguments passed to the command handler
* @param context The context object for the command
*/
on(event: 'preCommand', listener: (cmd: Command, msg: Eris.Message, args: string[], ctx: CommandContext) => void): this;
(event: 'preCommand', listener: (cmd: Command, msg: Eris.Message, args: string[], ctx: CommandContext) => void): T;
/**
* @event
* Fired after a command is executed.
Expand All @@ -389,7 +388,7 @@ export declare interface Client extends Eris.Client {
* @param args The arguments passed to the command handler
* @param context The context object for the command
*/
on(event: 'postCommand', listener: (cmd: Command, msg: Eris.Message, args: string[], ctx: CommandContext) => void): this;
(event: 'postCommand', listener: (cmd: Command, msg: Eris.Message, args: string[], ctx: CommandContext) => void): T;
/**
* @event
* Fired if a message starts with a command but no valid command is found
Expand All @@ -398,17 +397,9 @@ export declare interface Client extends Eris.Client {
* @param args The arguments passed to the command handler
* @param context The context object for the command
*/
on(event: 'invalidCommand', listener: (msg: Eris.Message, args: string[], ctx: CommandContext) => void): this;
(event: 'invalidCommand', listener: (msg: Eris.Message, args: string[], ctx: CommandContext) => void): T;
}

// Added event definitions
// export declare interface Client extends Eris.Client {
// on(event: string, listener: Function): this;
// on(event: 'preCommand' | 'command', listener: (
// command: Command,
// msg: Eris.Message,
// args: string[],
// ctx: CommandContext,
// ) => void): this;
// on(event: 'commandLoaded', listener: (command: Command) => void): this;
// }
export declare interface Client extends Eris.Client {
on: YuukoEvents<this>;
}

0 comments on commit b892b0b

Please sign in to comment.