diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index c90b78c6c..3008bf026 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -53,38 +53,30 @@ export type InteractionReturnable = | InteractionIterableReturnable | Promise; -type CommandRegistryBase = { - command: - | SlashCommandBuilder - | SlashCommandSubcommandsOnlyBuilder - | Omit; -}; -type CommandRegistryDefinitionBase = { +interface CommandRegistryBase { inProduction: boolean; inPublic: boolean; inPreview?: boolean; + command: + | SlashCommandBuilder + | SlashCommandSubcommandsOnlyBuilder + | Omit; + autocomplete?: (interaction: AutocompleteInteraction) => void; button?: (interaction: ButtonInteraction) => InteractionReturnable; -}; -type CommandRegistryDefinitionHandlesInteraction = { +} +interface CommandRegistryImplicit extends CommandRegistryBase { handlesInteraction: true; handler: (interaction: ChatInputCommandInteraction) => void; -}; -type CommandRegistryDefinitionDoesHandleInteraction = { +} +interface CommandRegistryExplicit extends CommandRegistryBase { handlesInteraction?: false; handler: ( interaction: ChatInputCommandInteraction, ) => InteractionReturnable; -}; -export type CommandRegistry = CommandRegistryBase & - (CommandRegistryDefinitionBase & - ( - | CommandRegistryDefinitionHandlesInteraction - | CommandRegistryDefinitionDoesHandleInteraction - )); - -const rest = new REST().setToken(secrets.DISCORD_TOKEN); +} +export type CommandRegistry = CommandRegistryImplicit | CommandRegistryExplicit; export const COMMANDS_RAW: Promise[] = [ permissionsCommand, @@ -118,6 +110,7 @@ export const commands = Promise.allSettled(COMMANDS_RAW).then((rawCommands) => { ); }); +const rest = new REST().setToken(secrets.DISCORD_TOKEN); export const guildCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = []; export const publicCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] =