From 1cab79f6fde6f367141c9f7ed91bcb70ed2e5c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Leit=C3=A3o?= <38259440+ImRodry@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:58:50 +0100 Subject: [PATCH] types(ModalSubmitFields): components is an array (#9406) * types(ModalSubmitFields): components is an array * types(ModalSubmitFields): make type coherent with docs * refactor(ModalSubmitInteraction): remove undefined props --- .../src/structures/ModalSubmitInteraction.js | 13 +++++++------ packages/discord.js/typings/index.d.ts | 10 ++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/discord.js/src/structures/ModalSubmitInteraction.js b/packages/discord.js/src/structures/ModalSubmitInteraction.js index f10eb476d..8f0ccf16c 100644 --- a/packages/discord.js/src/structures/ModalSubmitInteraction.js +++ b/packages/discord.js/src/structures/ModalSubmitInteraction.js @@ -88,12 +88,13 @@ class ModalSubmitInteraction extends BaseInteraction { * @returns {ModalData[]} */ static transformComponent(rawComponent) { - return { - value: rawComponent.value, - type: rawComponent.type, - customId: rawComponent.custom_id, - components: rawComponent.components?.map(c => this.transformComponent(c)), - }; + return rawComponent.components + ? { type: rawComponent.type, components: rawComponent.components.map(c => this.transformComponent(c)) } + : { + value: rawComponent.value, + type: rawComponent.type, + customId: rawComponent.custom_id, + }; } /** diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 87c47c465..2c48378b8 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -2228,17 +2228,15 @@ export interface TextInputModalData extends BaseModalData { export interface ActionRowModalData { type: ComponentType.ActionRow; - components: ModalData[]; + components: TextInputModalData[]; } -export type ModalData = TextInputModalData | ActionRowModalData; - export class ModalSubmitFields { constructor(components: ModalActionRowComponent[][]); - public components: ActionRow; + public components: ActionRowModalData[]; public fields: Collection; - public getField(customId: string, type: T): { type: T } & ModalData; - public getField(customId: string, type?: ComponentType): ModalData; + public getField(customId: string, type: T): { type: T } & TextInputModalData; + public getField(customId: string, type?: ComponentType): TextInputModalData; public getTextInputValue(customId: string): string; }