From 048072bdd771305b459d9a261c93a02ece5624d5 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sun, 5 Jun 2022 11:27:42 -0500 Subject: [PATCH] feat: make TextCommand and SlashCommand return more specific arg type --- src/handler/events/messageEvent.ts | 2 +- src/handler/structures/module.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index 9b5d7cc..b04d787 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -22,7 +22,7 @@ export const onMessageCreate = (wrapper: Wrapper) => { const [prefix, ...rest] = fmt(message, defaultPrefix); return { ctx: Context.wrap(message), - args: ['text', rest], + args: <['text', string[]]>['text', rest], mod: Files.TextCommands.text.get(prefix) ?? Files.BothCommands.get(prefix) ?? diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index d600650..3811660 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -15,7 +15,7 @@ import type { SelectMenuInteraction, UserContextMenuCommandInteraction, } from 'discord.js'; -import type { Args, Override } from '../../types/handler'; +import type { Args, Override, SlashOptions } from '../../types/handler'; import type { CommandPlugin, EventPlugin } from '../plugins/plugin'; import type Context from './context'; import { CommandType, PluginType } from './enums'; @@ -37,6 +37,7 @@ export type TextCommand = Override< onEvent: EventPlugin[]; plugins: CommandPlugin[]; alias?: string[]; + execute: (ctx: Context, args: ['text', string[]]) => Awaitable; } >; @@ -47,6 +48,7 @@ export type SlashCommand = Override< onEvent: EventPlugin[]; plugins: CommandPlugin[]; options?: SernOptionsData[]; + execute: (ctx: Context, args: ['slash', SlashOptions]) => Awaitable; } >;