fix: use in operator when resolving modal component (#11115)

This commit is contained in:
Naiyar
2025-09-26 14:40:51 +05:30
committed by GitHub
parent 2d740d5279
commit b3705df547
3 changed files with 5 additions and 7 deletions

View File

@@ -104,11 +104,10 @@ class ModalComponentResolver {
* Gets the value of a text input component * Gets the value of a text input component
* *
* @param {string} customId The custom id of the 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} * @returns {?string}
*/ */
getTextInputValue(customId, required = false) { getTextInputValue(customId) {
return this._getTypedComponent(customId, [ComponentType.TextInput], ['value'], required).value ?? null; return this._getTypedComponent(customId, [ComponentType.TextInput]).value;
} }
/** /**

View File

@@ -148,9 +148,9 @@ class ModalSubmitInteraction extends BaseInteraction {
}; };
// Text display components do not have custom ids. // 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) { if (rawComponent.values) {
data.values = rawComponent.values; data.values = rawComponent.values;

View File

@@ -2609,8 +2609,7 @@ export class ModalComponentResolver<Cached extends CacheType = CacheType> {
properties: string, properties: string,
required: boolean, required: boolean,
): ModalData; ): ModalData;
public getTextInputValue(customId: string, required: true): string; public getTextInputValue(customId: string): string;
public getTextInputValue(customId: string, required?: boolean): string | null;
public getStringSelectValues(customId: string): readonly string[]; public getStringSelectValues(customId: string): readonly string[];
public getSelectedUsers(customId: string, required: true): ReadonlyCollection<Snowflake, User>; public getSelectedUsers(customId: string, required: true): ReadonlyCollection<Snowflake, User>;
public getSelectedUsers(customId: string, required?: boolean): ReadonlyCollection<Snowflake, User> | null; public getSelectedUsers(customId: string, required?: boolean): ReadonlyCollection<Snowflake, User> | null;