Merge pull request #1112 from discordeno/cool-stuff

Slash Command Autocomplete
This commit is contained in:
Skillz4Killz
2021-11-11 08:24:16 -05:00
committed by GitHub
5 changed files with 8 additions and 0 deletions

View File

@@ -23,6 +23,8 @@ interface ApplicationCommandInteractionDataOptionBase<T extends DiscordApplicati
type: T;
/** The value of the pair */
value: V;
/** Whether the user has focused this option for autocompletion. */
focused?: true;
}
export interface ApplicationCommandInteractionDataOptionSubCommand

View File

@@ -16,6 +16,8 @@ export interface ApplicationCommandOption {
choices?: ApplicationCommandOptionChoice[];
/** If the option is a subcommand or subcommand group type, this nested options will be the parameters */
options?: ApplicationCommandOption[];
/** Whether this option should make autocomplete interactions. */
autocomplete?: boolean;
/** If the option is a channel type, the channels shown will be restricted to these types */
channelTypes?: ChannelTypes[];
}

View File

@@ -10,6 +10,8 @@ export enum DiscordInteractionResponseTypes {
DeferredUpdateMessage,
/** For components, edit the message the component was attached to */
UpdateMessage,
/** For Application Command Options, send an autocomplete result */
ApplicationCommandAutocompleteResult,
}
export type InteractionResponseTypes = DiscordInteractionResponseTypes;

View File

@@ -3,6 +3,7 @@ export enum DiscordInteractionTypes {
Ping = 1,
ApplicationCommand,
MessageComponent,
ApplicationCommandAutocomplete,
}
export type InteractionTypes = DiscordInteractionTypes;

View File

@@ -52,6 +52,7 @@ export function validateSlashOptionChoices(
});
}
// TODO: add checks for autocomplete options when discord provides more info about them.
export function validateSlashOptions(bot: Bot, options: ApplicationCommandOption[]) {
const requiredOptions: ApplicationCommandOption[] = [];
const optionalOptions: ApplicationCommandOption[] = [];