enum ApplicationCommandType {
ChatInput,
Message,
User
}
type A = {
type?: ApplicationCommandType.ChatInput
description: string
}
type B = {
type: ApplicationCommandType.Message
value: string
}
type C = {
type: ApplicationCommandType.User
value: string
}
type ChatInputCommandInteraction = string;
type ContextMenuCommandInteraction = number;
type Command<D extends string> =
| { type: ApplicationCommandType.ChatInput; description: D; execute(interaction: ChatInputCommandInteraction, options: [D]): Promise<unknown>; }
| { type: ApplicationCommandType.Message | ApplicationCommandType.User; description: D; execute(interaction: ContextMenuCommandInteraction, options: [D]): Promise<unknown>; }
export const createCommand = <C extends Command<D>, D extends string = C["description"]>(
command: C
) => command;
createCommand({
type: ApplicationCommandType.ChatInput,
description: "test",
async execute(interaction, options) {
}
})```