types(AutocompleteOption): backport fix and improve types

v13.8.1
This commit is contained in:
March 7th 2022-06-17 12:48:45 +07:00
parent 206c699844
commit 1cf045050c
2 changed files with 24 additions and 3 deletions

View File

@ -240,10 +240,19 @@ class CommandInteractionOptionResolver {
return option?.message ?? null; return option?.message ?? null;
} }
/**
* The full autocomplete option object.
* @typedef {Object} AutocompleteFocusedOption
* @property {string} name The name of the option
* @property {ApplicationCommandOptionType} type The type of the application command 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. * Gets the focused option.
* @param {boolean} [getFull=false] Whether to get the full option object * @param {boolean} [getFull=false] Whether to get the full option object
* @returns {string|number|ApplicationCommandOptionChoice} * @returns {string|AutocompleteFocusedOption}
* The value of the option, or the whole option if getFull is true * The value of the option, or the whole option if getFull is true
*/ */
getFocused(getFull = false) { getFocused(getFull = false) {

16
typings/index.d.ts vendored
View File

@ -886,8 +886,8 @@ export class CommandInteractionOptionResolver<Cached extends CacheType = CacheTy
): NonNullable<CommandInteractionOption<Cached>['member' | 'role' | 'user']> | null; ): NonNullable<CommandInteractionOption<Cached>['member' | 'role' | 'user']> | null;
public getMessage(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['message']>; public getMessage(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['message']>;
public getMessage(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['message']> | null; public getMessage(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['message']> | null;
public getFocused(getFull: true): ApplicationCommandOptionChoiceData; public getFocused(getFull: true): AutocompleteFocusedOption;
public getFocused(getFull?: boolean): string | number; public getFocused(getFull?: boolean): string;
public getAttachment(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['attachment']>; public getAttachment(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['attachment']>;
public getAttachment( public getAttachment(
name: string, name: string,
@ -4749,6 +4749,18 @@ export interface ConstantsClientApplicationAssetTypes {
BIG: 2; BIG: 2;
} }
export type AutocompleteFocusedOption = Pick<CommandInteractionOption, 'name'> & {
focused: true;
type:
| 'STRING'
| 'INTEGER'
| 'NUMBER'
| ApplicationCommandOptionTypes.STRING
| ApplicationCommandOptionTypes.INTEGER
| ApplicationCommandOptionTypes.NUMBER;
value: string;
};
export interface ConstantsColors { export interface ConstantsColors {
DEFAULT: 0x000000; DEFAULT: 0x000000;
WHITE: 0xffffff; WHITE: 0xffffff;