Skip to content

Commit

Permalink
update types for different command types
Browse files Browse the repository at this point in the history
  • Loading branch information
notunderctrl committed Sep 14, 2023
1 parent a2d81c4 commit 888cb87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 13 additions & 3 deletions packages/commandkit/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,26 @@ type LocaleString =
| 'uk'
| 'vi';

export type CommandData = {
type BaseCommandData = {
name: string;
description: string;
type?: CommandType;
name_localizations?: Partial<Record<LocaleString, string | null>>;
description_localizations?: Partial<Record<LocaleString, string | null>>;
dm_permission?: boolean;
default_member_permissions?: string;
nsfw?: boolean;
};

type ChatInputCommandData = BaseCommandData & {
type?: CommandType.ChatInput;
description: string;
description_localizations?: Partial<Record<LocaleString, string | null>>;
options?: Array<APIApplicationCommandOption>;
};

type UserOrMessageCommandData = BaseCommandData & {
type: CommandType.User | CommandType.Message;
};

export type CommandData = ChatInputCommandData | UserOrMessageCommandData;

export type CommandObject = Omit<CommandFileObject, 'run'>;
1 change: 0 additions & 1 deletion packages/commandkit/tests/commands/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { SlashCommandProps, CommandOptions, CommandData, CommandType } from '../
export const data: CommandData = {
name: 'ping',
description: 'Pong!',
type: CommandType.ChatInput,
};

export function run({ interaction, handler }: SlashCommandProps) {
Expand Down

0 comments on commit 888cb87

Please sign in to comment.