diff --git a/src/core/create-plugins.ts b/src/core/create-plugins.ts new file mode 100644 index 0000000..fa1bda9 --- /dev/null +++ b/src/core/create-plugins.ts @@ -0,0 +1,62 @@ +import { CommandType, EventType, PluginType } from '../structures'; +import type { Plugin, PluginResult, EventArgs, CommandArgs } from '../../types/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); +} diff --git a/src/core/index.ts b/src/core/index.ts index 5498a26..9494c0f 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,4 +1,4 @@ export * from './contracts'; -export * from './plugins'; +export * from './create-plugins'; export * from './structures'; export { single, transient, useContainerRaw, makeDependencies } from './dependencies';