From b3705df5474199d70b53175637c64ed9f5b0d441 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Fri, 26 Sep 2025 14:40:51 +0530 Subject: [PATCH] fix: use in operator when resolving modal component (#11115) --- packages/discord.js/src/structures/ModalComponentResolver.js | 5 ++--- packages/discord.js/src/structures/ModalSubmitInteraction.js | 4 ++-- packages/discord.js/typings/index.d.ts | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/discord.js/src/structures/ModalComponentResolver.js b/packages/discord.js/src/structures/ModalComponentResolver.js index 0ab7fcc53..149d14f92 100644 --- a/packages/discord.js/src/structures/ModalComponentResolver.js +++ b/packages/discord.js/src/structures/ModalComponentResolver.js @@ -104,11 +104,10 @@ class ModalComponentResolver { * Gets the value of a text input component * * @param {string} customId The custom id of the text input component - * @param {?boolean} required Whether to throw an error if the component value is not found or empty * @returns {?string} */ - getTextInputValue(customId, required = false) { - return this._getTypedComponent(customId, [ComponentType.TextInput], ['value'], required).value ?? null; + getTextInputValue(customId) { + return this._getTypedComponent(customId, [ComponentType.TextInput]).value; } /** diff --git a/packages/discord.js/src/structures/ModalSubmitInteraction.js b/packages/discord.js/src/structures/ModalSubmitInteraction.js index 7e595757d..2cb92f1d1 100644 --- a/packages/discord.js/src/structures/ModalSubmitInteraction.js +++ b/packages/discord.js/src/structures/ModalSubmitInteraction.js @@ -148,9 +148,9 @@ class ModalSubmitInteraction extends BaseInteraction { }; // Text display components do not have custom ids. - if (rawComponent.custom_id) data.customId = rawComponent.custom_id; + if ('custom_id' in rawComponent) data.customId = rawComponent.custom_id; - if (rawComponent.value) data.value = rawComponent.value; + if ('value' in rawComponent) data.value = rawComponent.value; if (rawComponent.values) { data.values = rawComponent.values; diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 659389d71..7de0b0abc 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -2609,8 +2609,7 @@ export class ModalComponentResolver { properties: string, required: boolean, ): ModalData; - public getTextInputValue(customId: string, required: true): string; - public getTextInputValue(customId: string, required?: boolean): string | null; + public getTextInputValue(customId: string): string; public getStringSelectValues(customId: string): readonly string[]; public getSelectedUsers(customId: string, required: true): ReadonlyCollection; public getSelectedUsers(customId: string, required?: boolean): ReadonlyCollection | null;