diff --git a/src/commands/CommandManager.ts b/src/commands/CommandManager.ts index dd09b3f..a2ea341 100644 --- a/src/commands/CommandManager.ts +++ b/src/commands/CommandManager.ts @@ -1,8 +1,9 @@ import { Interaction, Message } from "discord.js"; import { BaseCommand } from "./BaseCommand.js"; import { ChatCommand } from "./ChatCommand.js"; +import { MessageCommand } from "./MessageCommand.js"; import { CommandType } from "./types/BaseCommand.js"; -import { Command, CommandInteractionData, CommandList } from "./types/commands.js"; +import { CommandInteractionData } from "./types/commands.js"; export class CommandManager { private readonly _commands: BaseCommand[] = []; @@ -16,23 +17,21 @@ export class CommandManager { public add(command: BaseCommand): void {} - public get(q: string, t?: T): Command | null { + public get(q: string, t?: undefined): BaseCommand | null; + public get(q: string, t: "CHAT"): ChatCommand | null; + public get(q: string, t: "MESSAGE"): MessageCommand | null; + public get(q: string, t?: CommandType): BaseCommand | null { return null; } - public list(filter?: T): CommandList { - switch (filter) { - case "CHAT": - return Object.freeze([...this._commands.filter((c) => c.type === "CHAT")]) as CommandList; - case "USER": - case "MESSAGE": - return Object.freeze([...this._commands.filter((c) => c.type === "MESSAGE" || c.type === "USER")]) as CommandList; - default: - return Object.freeze([...this._commands]) as CommandList; - } + public list(): BaseCommand[]; + public list(f: "CHAT"): ChatCommand[]; + public list(f: "MESSAGE"): MessageCommand[]; + public list(f?: CommandType): BaseCommand[] { + return []; } - public fetch(i: T): CommandInteractionData | null { + public fetch(interaction: T): CommandInteractionData | null { return null; } } diff --git a/src/commands/types/commands.ts b/src/commands/types/commands.ts index da2ecfa..3a355fc 100644 --- a/src/commands/types/commands.ts +++ b/src/commands/types/commands.ts @@ -3,21 +3,11 @@ import { ChatCommand } from "../ChatCommand.js"; import { MessageCommand } from "../MessageCommand.js"; import { UserCommand } from "../UserCommand.js"; import { InputParameter } from "../../structures/Parameter.js"; -import { CommandType } from "./BaseCommand.js"; - -export type Command = T extends "CHAT" ? ChatCommand : T extends "MESSAGE" ? MessageCommand : T extends "USER" ? MessageCommand : BaseCommand; - -export type CommandList = T extends "CHAT" - ? readonly ChatCommand[] - : T extends "MESSAGE" - ? readonly MessageCommand[] - : T extends "USER" - ? readonly MessageCommand[] - : readonly BaseCommand[]; +import { Interaction, Message } from "discord.js"; export type CommandResolvable = BaseCommand | ChatCommand | MessageCommand | UserCommand; -export interface CommandInteractionData { - command: T; +export interface CommandInteractionData { + command: T extends Interaction ? BaseCommand : ChatCommand; parameters: InputParameter[]; }