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;