types(AutocompleteOption): fix and improve types (#8069)

This commit is contained in:
Rodry
2022-06-13 17:15:31 +01:00
committed by GitHub
parent 10a6c4287d
commit 476b7d519c
2 changed files with 13 additions and 6 deletions

View File

@@ -258,17 +258,17 @@ class CommandInteractionOptionResolver {
/**
* The full autocomplete option object.
* @typedef {Object} AutocompleteOption
* @typedef {Object} AutocompleteFocusedOption
* @property {string} name The name of the option
* @property {ApplicationCommandOptionType} type The type of the application command option
* @property {string|number} value The value of the option
* @property {string} value The value of the option
* @property {boolean} focused Whether this option is currently in focus for autocomplete
*/
/**
* Gets the focused option.
* @param {boolean} [getFull=false] Whether to get the full option object
* @returns {string|number|AutocompleteOption}
* @returns {string|AutocompleteFocusedOption}
* The value of the option, or the whole option if getFull is true
*/
getFocused(getFull = false) {

View File

@@ -1007,8 +1007,8 @@ export class CommandInteractionOptionResolver<Cached extends CacheType = CacheTy
): NonNullable<CommandInteractionOption<Cached>['member' | 'role' | 'user']> | null;
public getMessage(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['message']>;
public getMessage(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['message']> | null;
public getFocused(getFull: true): AutocompleteOption;
public getFocused(getFull?: boolean): string | number;
public getFocused(getFull: true): AutocompleteFocusedOption;
public getFocused(getFull?: boolean): string;
}
export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType> extends CommandInteraction<Cached> {
@@ -4064,7 +4064,14 @@ export interface CommandInteractionResolvedData<Cached extends CacheType = Cache
attachments?: Collection<Snowflake, Attachment>;
}
export type AutocompleteOption = Pick<CommandInteractionOption, 'name' | 'type' | 'value' | 'focused'>;
export type AutocompleteFocusedOption = Pick<CommandInteractionOption, 'name'> & {
focused: true;
type:
| ApplicationCommandOptionType.String
| ApplicationCommandOptionType.Integer
| ApplicationCommandOptionType.Number;
value: string;
};
export declare const Colors: {
Default: 0x000000;