refactor(CommandInteractionOptionResolver): remove getFull from getFocused() (#9789)

* refactor(CommandInteractionOptionResolver): remove getFull from getFocused()

* docs: update return type

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Rodrigo Leitão
2024-10-01 17:21:42 +01:00
committed by GitHub
parent ab32f26cbb
commit 493a079fdf
2 changed files with 5 additions and 7 deletions

View File

@@ -294,14 +294,13 @@ class CommandInteractionOptionResolver {
/** /**
* Gets the focused option. * Gets the focused option.
* @param {boolean} [getFull=false] Whether to get the full option object * @returns {AutocompleteFocusedOption}
* @returns {string|AutocompleteFocusedOption} * The whole object of the option that is focused
* The value of the option, or the whole option if getFull is true
*/ */
getFocused(getFull = false) { getFocused() {
const focusedOption = this._hoistedOptions.find(option => option.focused); const focusedOption = this._hoistedOptions.find(option => option.focused);
if (!focusedOption) throw new DiscordjsTypeError(ErrorCodes.AutocompleteInteractionOptionNoFocusedOption); if (!focusedOption) throw new DiscordjsTypeError(ErrorCodes.AutocompleteInteractionOptionNoFocusedOption);
return getFull ? focusedOption : focusedOption.value; return focusedOption;
} }
} }

View File

@@ -1312,8 +1312,7 @@ 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): AutocompleteFocusedOption; public getFocused(): AutocompleteFocusedOption;
public getFocused(getFull?: boolean): string;
} }
export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType> extends CommandInteraction<Cached> { export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType> extends CommandInteraction<Cached> {