From 98cdcf85239930693ff382067c847d4848862e67 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 23 May 2024 22:02:27 -0700 Subject: [PATCH] chore: create command output type --- src/structures/Command.ts | 4 ++-- types.d.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/structures/Command.ts b/src/structures/Command.ts index 5aff06b..52b87e2 100644 --- a/src/structures/Command.ts +++ b/src/structures/Command.ts @@ -1,4 +1,4 @@ -import type { CommandContext, CommandOptions, PartialCommandContext } from '@/types' +import type { CommandContext, CommandOptions, PartialCommandContext, CommandOutput } from '@/types' import type { Blop } from '@/structures' import type { APIApplicationCommandOption, APIEmbed } from 'discord.js' @@ -67,7 +67,7 @@ export class Command { * @param {CommandContext} context - The command context. * @throws {Error} If the command doesn't have an execute method. */ - execute(context: CommandContext): string | { content?: string; embeds?: APIEmbed[]; files?: any[]; components?: any[] } | null | undefined | void | Promise { + execute(context: CommandContext): CommandOutput { throw new Error(`${this.name} doesn't have an execute() method.`) } } diff --git a/types.d.ts b/types.d.ts index 8d35756..9144e52 100644 --- a/types.d.ts +++ b/types.d.ts @@ -1,6 +1,7 @@ import type { Blop } from '@/structures' import type { APIApplicationCommandOption, + APIEmbed, ChatInputCommandInteraction, Snowflake } from 'discord.js' @@ -29,3 +30,5 @@ export interface PartialCommandContext { client: Blop interaction?: ChatInputCommandInteraction<'cached'> } + +export type CommandOutput = string | { content?: string; embeds?: APIEmbed[]; files?: any[]; components?: any[] } | null | undefined | void | Promise