From e6f9207a472df1357021772c89de3522be12c8e9 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 27 Apr 2023 13:22:15 -0500 Subject: [PATCH] chore: move command args matrix as binding --- src/core/plugins/args.ts | 103 +------------------------------ src/core/plugins/createPlugin.ts | 1 + 2 files changed, 4 insertions(+), 100 deletions(-) diff --git a/src/core/plugins/args.ts b/src/core/plugins/args.ts index 9496041..baa48f1 100644 --- a/src/core/plugins/args.ts +++ b/src/core/plugins/args.ts @@ -1,106 +1,9 @@ import type { CommandType } from '../structures/enums'; import type { PluginType } from '../structures/enums'; -import type { ClientEvents } from 'discord.js'; -import type { - BothCommand, - ButtonCommand, - ChannelSelectCommand, - ContextMenuUser, - DiscordEventCommand, - ExternalEventCommand, - MentionableSelectCommand, - ModalSubmitCommand, - RoleSelectCommand, - SernEventCommand, - SlashCommand, - StringSelectCommand, - TextCommand, - UserSelectCommand, - ContextMenuMsg, - Module, -} from '../../types/module'; -import type { Args, Payload, Processed, SlashOptions } from '../../types/handler'; -import type { Context } from '../structures/context'; -import type { MessageContextMenuCommandInteraction } from 'discord.js'; -import type { - ButtonInteraction, - RoleSelectMenuInteraction, - StringSelectMenuInteraction, - UserContextMenuCommandInteraction, -} from 'discord.js'; -import type { - ChannelSelectMenuInteraction, - MentionableSelectMenuInteraction, - ModalSubmitInteraction, - UserSelectMenuInteraction, -} from 'discord.js'; +import type { Module } from '../../types/module'; +import type { Processed } from '../../types/handler'; import { EventType } from '../structures/enums'; - -type CommandArgsMatrix = { - [CommandType.Text]: { - [PluginType.Control]: [Context, ['text', string[]]]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.Slash]: { - [PluginType.Control]: [Context, ['slash', /* library coupled */ SlashOptions]]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.Both]: { - [PluginType.Control]: [Context, Args]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.CtxMsg]: { - [PluginType.Control]: [/* library coupled */ MessageContextMenuCommandInteraction]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.CtxUser]: { - [PluginType.Control]: [/* library coupled */ UserContextMenuCommandInteraction]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.Button]: { - [PluginType.Control]: [/* library coupled */ ButtonInteraction]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.StringSelect]: { - [PluginType.Control]: [/* library coupled */ StringSelectMenuInteraction]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.RoleSelect]: { - [PluginType.Control]: [/* library coupled */ RoleSelectMenuInteraction]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.ChannelSelect]: { - [PluginType.Control]: [/* library coupled */ ChannelSelectMenuInteraction]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.MentionableSelect]: { - [PluginType.Control]: [/* library coupled */ MentionableSelectMenuInteraction]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.UserSelect]: { - [PluginType.Control]: [/* library coupled */ UserSelectMenuInteraction]; - [PluginType.Init]: [InitArgs>]; - }; - [CommandType.Modal]: { - [PluginType.Control]: [/* library coupled */ ModalSubmitInteraction]; - [PluginType.Init]: [InitArgs>]; - }; -}; - -type EventArgsMatrix = { - [EventType.Discord]: { - [PluginType.Control]: /* library coupled */ ClientEvents[keyof ClientEvents]; - [PluginType.Init]: [InitArgs>]; - }; - [EventType.Sern]: { - [PluginType.Control]: [Payload]; - [PluginType.Init]: [InitArgs>]; - }; - [EventType.External]: { - [PluginType.Control]: unknown[]; - [PluginType.Init]: [InitArgs>]; - }; -}; +import { CommandArgsMatrix, EventArgsMatrix } from '../../entrypoints/djs'; export interface InitArgs> { module: T; diff --git a/src/core/plugins/createPlugin.ts b/src/core/plugins/createPlugin.ts index fef8cda..8578285 100644 --- a/src/core/plugins/createPlugin.ts +++ b/src/core/plugins/createPlugin.ts @@ -3,6 +3,7 @@ import type { Plugin, PluginResult } from '../../types/plugin'; import type { CommandArgs, EventArgs } from './args'; import type { ClientEvents } from 'discord.js'; export const guayin = Symbol('twice<3'); + export function makePlugin( type: PluginType, execute: (...args: any[]) => any,