import type { ClientEvents } from 'discord.js'; import { EventType } from '../core/structures/enums'; import type { InputCommand, InputEvent, Module, } from '../types/core-modules'; import { partitionPlugins } from './functions' import type { Awaitable } from '../types/utility'; /** * @since 1.0.0 The wrapper function to define command modules for sern * @param mod */ export function commandModule(mod: InputCommand): Module { const [onEvent, plugins] = partitionPlugins(mod.plugins); return { ...mod, onEvent, plugins, } as Module; } /** * @since 1.0.0 * The wrapper function to define event modules for sern * @param mod */ export function eventModule(mod: InputEvent): Module { return mod as Module; } /** Create event modules from discord.js client events, * This is an {@link eventModule} for discord events, * where typings can be very bad. * @Experimental * @param mod */ export function discordEvent(mod: { name: T; execute: (...args: ClientEvents[T]) => Awaitable; }) { return eventModule({ type: EventType.Discord, ...mod, }); }