Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -294,14 +294,13 @@ class CommandInteractionOptionResolver {

/**
* Gets the focused option.
* @param {boolean} [getFull=false] Whether to get the full option object
* @returns {string|AutocompleteFocusedOption}
ImRodry marked this conversation as resolved.
Show resolved Hide resolved
* The value of the option, or the whole option if getFull is true
* The whole object of the option that is focused
*/
getFocused(getFull = false) {
getFocused() {
const focusedOption = this._hoistedOptions.find(option => option.focused);
if (!focusedOption) throw new DiscordjsTypeError(ErrorCodes.AutocompleteInteractionOptionNoFocusedOption);
return getFull ? focusedOption : focusedOption.value;
return focusedOption;
}
}

Expand Down
3 changes: 1 addition & 2 deletions packages/discord.js/typings/index.d.ts
Expand Up @@ -1234,8 +1234,7 @@ 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): AutocompleteFocusedOption;
public getFocused(getFull?: boolean): string;
public getFocused(): AutocompleteFocusedOption;
}

export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType> extends CommandInteraction<Cached> {
Expand Down