Skip to content

Commit 888cb87

Browse files
committed
update types for different command types
1 parent a2d81c4 commit 888cb87

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/commandkit/src/types/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,26 @@ type LocaleString =
8282
| 'uk'
8383
| 'vi';
8484

85-
export type CommandData = {
85+
type BaseCommandData = {
8686
name: string;
87-
description: string;
8887
type?: CommandType;
8988
name_localizations?: Partial<Record<LocaleString, string | null>>;
90-
description_localizations?: Partial<Record<LocaleString, string | null>>;
9189
dm_permission?: boolean;
9290
default_member_permissions?: string;
9391
nsfw?: boolean;
92+
};
93+
94+
type ChatInputCommandData = BaseCommandData & {
95+
type?: CommandType.ChatInput;
96+
description: string;
97+
description_localizations?: Partial<Record<LocaleString, string | null>>;
9498
options?: Array<APIApplicationCommandOption>;
9599
};
96100

101+
type UserOrMessageCommandData = BaseCommandData & {
102+
type: CommandType.User | CommandType.Message;
103+
};
104+
105+
export type CommandData = ChatInputCommandData | UserOrMessageCommandData;
106+
97107
export type CommandObject = Omit<CommandFileObject, 'run'>;

packages/commandkit/tests/commands/ping.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { SlashCommandProps, CommandOptions, CommandData, CommandType } from '../
33
export const data: CommandData = {
44
name: 'ping',
55
description: 'Pong!',
6-
type: CommandType.ChatInput,
76
};
87

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

0 commit comments

Comments
 (0)