From 493a079fdf5864ce7e2965025ebe840e61fc988d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Leit=C3=A3o?= <38259440+ImRodry@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:21:42 +0100 Subject: [PATCH] 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> --- .../src/structures/CommandInteractionOptionResolver.js | 9 ++++----- packages/discord.js/typings/index.d.ts | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/discord.js/src/structures/CommandInteractionOptionResolver.js b/packages/discord.js/src/structures/CommandInteractionOptionResolver.js index 621dbf44e..b59f6328e 100644 --- a/packages/discord.js/src/structures/CommandInteractionOptionResolver.js +++ b/packages/discord.js/src/structures/CommandInteractionOptionResolver.js @@ -294,14 +294,13 @@ class CommandInteractionOptionResolver { /** * Gets the focused option. - * @param {boolean} [getFull=false] Whether to get the full option object - * @returns {string|AutocompleteFocusedOption} - * The value of the option, or the whole option if getFull is true + * @returns {AutocompleteFocusedOption} + * 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; } } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index c28be6290..ef876764c 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1312,8 +1312,7 @@ export class CommandInteractionOptionResolver['member' | 'role' | 'user']> | null; public getMessage(name: string, required: true): NonNullable['message']>; public getMessage(name: string, required?: boolean): NonNullable['message']> | null; - public getFocused(getFull: true): AutocompleteFocusedOption; - public getFocused(getFull?: boolean): string; + public getFocused(): AutocompleteFocusedOption; } export class ContextMenuCommandInteraction extends CommandInteraction {