feat: Add more typings for event modules

This commit is contained in:
Jacob Nguyen
2022-06-26 12:51:21 -05:00
parent ce06e8158a
commit c3b16b43ce
2 changed files with 13 additions and 12 deletions

View File

@@ -154,7 +154,7 @@ function autoCmpHandler(mod: Module | undefined, interaction: AutocompleteIntera
const selectedOption = mod.options?.find(o => o.autocomplete && o.name === choice.name);
if (selectedOption !== undefined && selectedOption.autocomplete) {
return of(
selectedOption.command.onEvent.map(e => e.execute([interaction], controller)),
selectedOption.command.onEvent.map(e => e.execute(interaction, controller)),
).pipe(
map(res => ({
mod,

View File

@@ -1,21 +1,22 @@
import type { Override, SernEventsMapping } from '../../types/handler';
import type { BaseModule } from './module';
import type { BaseModule, EventModuleDefs } from './module';
import type {
CommandPlugin,
EventPlugin,
DiscordEmitterPlugin,
ExternalEmitterPlugin,
ExternalEventPlugin,
SernEmitterPlugin,
SernEventPlugin,
} from '../plugins/plugin';
import type { CommandType } from './enums';
import type { Awaitable, ClientEvents } from 'discord.js';
import type { EventType } from './enums';
export type SernEventCommand<T extends keyof SernEventsMapping = keyof SernEventsMapping> =
Override<
BaseModule,
{
name?: T;
type: CommandType.Sern;
onEvent: EventPlugin<CommandType.Sern>[];
type: EventType.Sern;
onEvent: SernEventPlugin[];
plugins: SernEmitterPlugin[];
execute(...args: SernEventsMapping[T]): Awaitable<void | unknown>;
}
@@ -24,9 +25,9 @@ export type DiscordEventCommand<T extends keyof ClientEvents = keyof ClientEvent
BaseModule,
{
name?: T;
type: CommandType.Discord;
onEvent: EventPlugin<CommandType.Discord>[];
plugins: CommandPlugin[];
type: EventType.Discord;
onEvent: DiscordEventCommand[];
plugins: DiscordEmitterPlugin[];
execute(...args: ClientEvents[T]): Awaitable<void | unknown>;
}
>;
@@ -35,8 +36,8 @@ export type ExternalEventCommand = Override<
BaseModule,
{
emitter: string;
type: CommandType.External;
onEvent: EventPlugin<CommandType.External>[];
type: EventType.External;
onEvent: ExternalEventPlugin[];
plugins: ExternalEmitterPlugin[];
execute(...args: unknown[]): Awaitable<void | unknown>;
}