Skip to content

Commit

Permalink
chore: create command output type
Browse files Browse the repository at this point in the history
  • Loading branch information
dankerow committed May 28, 2024
1 parent a48570b commit 98cdcf8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/structures/Command.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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<string | { content?: string; embeds?: APIEmbed[]; files?: any[]; components?: any[] } | null | undefined | void> {
execute(context: CommandContext): CommandOutput {
throw new Error(`${this.name} doesn't have an execute() method.`)
}
}
3 changes: 3 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Blop } from '@/structures'
import type {
APIApplicationCommandOption,
APIEmbed,
ChatInputCommandInteraction,
Snowflake
} from 'discord.js'
Expand Down Expand Up @@ -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<string | { content?: string; embeds?: APIEmbed[]; files?: any[]; components?: any[] } | null | undefined | void>

0 comments on commit 98cdcf8

Please sign in to comment.