mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: simpler command types
This commit is contained in:
1 parent
adad668157
commit
49d0dbe86d
1 file changed
+13
-20
@@ -53,38 +53,30 @@ export type InteractionReturnable =
|
|||||||
| InteractionIterableReturnable
|
| InteractionIterableReturnable
|
||||||
| Promise<InteractionIterableReturnable>;
|
| Promise<InteractionIterableReturnable>;
|
||||||
|
|
||||||
type CommandRegistryBase = {
|
interface CommandRegistryBase {
|
||||||
command:
|
|
||||||
| SlashCommandBuilder
|
|
||||||
| SlashCommandSubcommandsOnlyBuilder
|
|
||||||
| Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
|
||||||
};
|
|
||||||
type CommandRegistryDefinitionBase = {
|
|
||||||
inProduction: boolean;
|
inProduction: boolean;
|
||||||
inPublic: boolean;
|
inPublic: boolean;
|
||||||
inPreview?: boolean;
|
inPreview?: boolean;
|
||||||
|
|
||||||
|
command:
|
||||||
|
| SlashCommandBuilder
|
||||||
|
| SlashCommandSubcommandsOnlyBuilder
|
||||||
|
| Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
||||||
|
|
||||||
autocomplete?: (interaction: AutocompleteInteraction<CacheType>) => void;
|
autocomplete?: (interaction: AutocompleteInteraction<CacheType>) => void;
|
||||||
button?: (interaction: ButtonInteraction<CacheType>) => InteractionReturnable;
|
button?: (interaction: ButtonInteraction<CacheType>) => InteractionReturnable;
|
||||||
};
|
}
|
||||||
type CommandRegistryDefinitionHandlesInteraction = {
|
interface CommandRegistryImplicit extends CommandRegistryBase {
|
||||||
handlesInteraction: true;
|
handlesInteraction: true;
|
||||||
handler: (interaction: ChatInputCommandInteraction<CacheType>) => void;
|
handler: (interaction: ChatInputCommandInteraction<CacheType>) => void;
|
||||||
};
|
}
|
||||||
type CommandRegistryDefinitionDoesHandleInteraction = {
|
interface CommandRegistryExplicit extends CommandRegistryBase {
|
||||||
handlesInteraction?: false;
|
handlesInteraction?: false;
|
||||||
handler: (
|
handler: (
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
) => InteractionReturnable;
|
) => InteractionReturnable;
|
||||||
};
|
}
|
||||||
export type CommandRegistry = CommandRegistryBase &
|
export type CommandRegistry = CommandRegistryImplicit | CommandRegistryExplicit;
|
||||||
(CommandRegistryDefinitionBase &
|
|
||||||
(
|
|
||||||
| CommandRegistryDefinitionHandlesInteraction
|
|
||||||
| CommandRegistryDefinitionDoesHandleInteraction
|
|
||||||
));
|
|
||||||
|
|
||||||
const rest = new REST().setToken(secrets.DISCORD_TOKEN);
|
|
||||||
|
|
||||||
export const COMMANDS_RAW: Promise<CommandRegistry>[] = [
|
export const COMMANDS_RAW: Promise<CommandRegistry>[] = [
|
||||||
permissionsCommand,
|
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 guildCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] =
|
||||||
[];
|
[];
|
||||||
export const publicCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] =
|
export const publicCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] =
|
||||||
|
|||||||
Reference in new issue
Block a user