diff --git a/src/Interactions/definitions.ts b/src/Interactions/definitions.ts index 0c13c20..fa34dd0 100644 --- a/src/Interactions/definitions.ts +++ b/src/Interactions/definitions.ts @@ -22,13 +22,13 @@ export type InteractionResponse = data: Discord.InteractionCallbackAutocomplete } -type EnforceDescription = T extends { +type DescriptionMissing = A extends { type: Exclude } - ? T - : T extends { description: string } - ? T - : "description is missing" + ? false + : A extends { description: string } + ? false + : true export type InteractionDefinition = | GlobalApplicationCommand @@ -50,13 +50,15 @@ export const global = < E, A extends Discord.CreateGlobalApplicationCommandParams, >( - command: EnforceDescription, - handle: Effect, + command: A, + handle: DescriptionMissing extends true + ? "command description is missing" + : Effect, ) => new GlobalApplicationCommand< Exclude, E - >(command as any, handle as any) + >(command, handle as any) export class GuildApplicationCommand { readonly _tag = "GuildApplicationCommand" @@ -71,13 +73,15 @@ export const guild = < E, A extends Discord.CreateGuildApplicationCommandParams, >( - command: EnforceDescription, - handle: Effect, + command: A, + handle: DescriptionMissing extends true + ? "command description is missing" + : Effect, ) => new GuildApplicationCommand< Exclude, E - >(command as any, handle as any) + >(command, handle as any) export class MessageComponent { readonly _tag = "MessageComponent"