feat: make TextCommand and SlashCommand return more specific arg type

This commit is contained in:
Jacob Nguyen
2022-06-05 12:42:17 -05:00
parent 048072bdd7
commit ef357e90af
2 changed files with 12 additions and 12 deletions

View File

@@ -1,6 +1,5 @@
import type { Message } from 'discord.js';
import { concatMap, from, fromEvent, map, Observable, of } from 'rxjs';
import type { Args } from '../..';
import { controller } from '../sern';
import Context from '../structures/context';
import type Wrapper from '../structures/wrapper';

View File

@@ -26,7 +26,7 @@ export interface BaseModule {
type: CommandType | PluginType;
name?: string;
description: string;
execute: (ctx: Context, args: Args) => Awaitable<void | unknown>;
execute: (...args: unknown[]) => Awaitable<void | unknown>;
}
//possible refactoring types into interfaces and not types
@@ -34,8 +34,8 @@ export type TextCommand = Override<
BaseModule,
{
type: CommandType.Text;
onEvent: EventPlugin<CommandType.Text>[];
plugins: CommandPlugin[];
onEvent: EventPlugin<CommandType.Text>[]; //maybe allow BothPlugins for this also?
plugins: CommandPlugin<CommandType.Text>[]; //maybe allow BothPlugins for this also?
alias?: string[];
execute: (ctx: Context, args: ['text', string[]]) => Awaitable<void | unknown>;
}
@@ -45,8 +45,8 @@ export type SlashCommand = Override<
BaseModule,
{
type: CommandType.Slash;
onEvent: EventPlugin<CommandType.Slash>[];
plugins: CommandPlugin[];
onEvent: EventPlugin<CommandType.Slash>[]; //maybe allow BothPlugins for this also?
plugins: CommandPlugin<CommandType.Slash>[]; //maybe allow BothPlugins for this also?
options?: SernOptionsData[];
execute: (ctx: Context, args: ['slash', SlashOptions]) => Awaitable<void | unknown>;
}
@@ -57,9 +57,10 @@ export type BothCommand = Override<
{
type: CommandType.Both;
onEvent: EventPlugin<CommandType.Both>[];
plugins: CommandPlugin[];
plugins: CommandPlugin<CommandType.Both>[];
alias?: string[];
options?: SernOptionsData[];
execute: (ctx: Context, args: Args) => Awaitable<void | unknown>;
}
>;
@@ -68,7 +69,7 @@ export type ContextMenuUser = Override<
{
type: CommandType.MenuUser;
onEvent: EventPlugin<CommandType.MenuUser>[];
plugins: CommandPlugin[];
plugins: CommandPlugin<CommandType.MenuUser>[];
execute: (ctx: UserContextMenuCommandInteraction) => Awaitable<void | unknown>;
}
>;
@@ -78,7 +79,7 @@ export type ContextMenuMsg = Override<
{
type: CommandType.MenuMsg;
onEvent: EventPlugin<CommandType.MenuMsg>[];
plugins: CommandPlugin[];
plugins: CommandPlugin<CommandType.MenuMsg>[];
execute: (ctx: MessageContextMenuCommandInteraction) => Awaitable<void | unknown>;
}
>;
@@ -88,7 +89,7 @@ export type ButtonCommand = Override<
{
type: CommandType.Button;
onEvent: EventPlugin<CommandType.Button>[];
plugins: CommandPlugin[];
plugins: CommandPlugin<CommandType.Button>[];
execute: (ctx: ButtonInteraction) => Awaitable<void | unknown>;
}
>;
@@ -98,7 +99,7 @@ export type SelectMenuCommand = Override<
{
type: CommandType.MenuSelect;
onEvent: EventPlugin<CommandType.MenuSelect>[];
plugins: CommandPlugin[];
plugins: CommandPlugin<CommandType.MenuSelect>[];
execute: (ctx: SelectMenuInteraction) => Awaitable<void | unknown>;
}
>;
@@ -108,7 +109,7 @@ export type ModalSubmitCommand = Override<
{
type: CommandType.Modal;
onEvent: EventPlugin<CommandType.Modal>[];
plugins: CommandPlugin[];
plugins: CommandPlugin<CommandType.Modal>[];
execute: (ctx: ModalSubmitInteraction) => Awaitable<void | unknown>;
}
>;