import { CommandType, EventType, PluginType } from './structures'; import type { Plugin, PluginResult, EventArgs, CommandArgs } from '../types/core-plugin'; import type { ClientEvents } from 'discord.js'; export function makePlugin( type: PluginType, execute: (...args: any[]) => any, ): Plugin { return { type, execute, } as Plugin; } /** * @since 2.5.0 * @__PURE__ */ export function EventInitPlugin( execute: (...args: EventArgs) => PluginResult, ) { return makePlugin(PluginType.Init, execute); } /** * @since 2.5.0 * @__PURE__ */ export function CommandInitPlugin( execute: (...args: CommandArgs) => PluginResult, ) { return makePlugin(PluginType.Init, execute); } /** * @since 2.5.0 * @__PURE__ */ export function CommandControlPlugin( execute: (...args: CommandArgs) => PluginResult, ) { return makePlugin(PluginType.Control, execute); } /** * @since 2.5.0 * @__PURE__ */ export function EventControlPlugin( execute: (...args: EventArgs) => PluginResult, ) { return makePlugin(PluginType.Control, execute); } /** * @since 2.5.0 * @Experimental * A specialized function for creating control plugins with discord.js ClientEvents. * Will probably be moved one day! */ export function DiscordEventControlPlugin( name: T, execute: (...args: ClientEvents[T]) => PluginResult, ) { return makePlugin(PluginType.Control, execute); }