Skip to content

Commit

Permalink
add reciple custom events :)
Browse files Browse the repository at this point in the history
  • Loading branch information
catplvsplus committed Jun 21, 2022
1 parent be79a2a commit 8f4d7e1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/reciple/classes/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// and accidentally made it unreadable for humans. So, if you're
// trying to understand this code, please, consider being a dog first.

import { ApplicationCommandDataResolvable, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
import { ApplicationCommandDataResolvable, Awaitable, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
import { InteractionCommandBuilder, RecipleInteractionCommandExecute } from './builders/InteractionCommandBuilder';
import { loadModules, recipleCommandBuilders, recipleCommandBuildersExecute, RecipleScript } from '../modules';
import { interactionCommandBuilders, registerInteractionCommands } from '../registerInteractionCommands';
Expand All @@ -26,13 +26,28 @@ export interface RecipleClientCommands {
INTERACTION_COMMANDS: { [commandName: string]: InteractionCommandBuilder };
}

// TODO: Add these events to the client
// TODO: Learn to add these bitch to the client
export interface RecipleClientEvents extends ClientEvents {
recipleMessageCommandCreate: [command: RecipleMessageCommandExecute];
recipleInteractionCommandCreate: [command: RecipleInteractionCommandExecute];
}

export interface RecipleClient extends Client {
on<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
on<E extends string|symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;

once<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
once<E extends keyof string|symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;

emit<E extends keyof RecipleClientEvents>(event: E, ...args: RecipleClientEvents[E]): boolean;
emit<E extends string|symbol>(event: Exclude<E, keyof RecipleClientEvents>, ...args: any): boolean;

off<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
off<E extends string|symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;

removeAllListeners<E extends keyof RecipleClientEvents>(event?: E): this;
removeAllListeners(event?: string|symbol): this;
}

export class RecipleClient extends Client {
public config?: Config;
public commands: RecipleClientCommands = { MESSAGE_COMMANDS: {}, INTERACTION_COMMANDS: {} };
Expand Down

0 comments on commit 8f4d7e1

Please sign in to comment.