Skip to content

Commit 1cab79f

Browse files
authored
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
1 parent 7b494ac commit 1cab79f

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

packages/discord.js/src/structures/ModalSubmitInteraction.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ class ModalSubmitInteraction extends BaseInteraction {
8888
* @returns {ModalData[]}
8989
*/
9090
static transformComponent(rawComponent) {
91-
return {
92-
value: rawComponent.value,
93-
type: rawComponent.type,
94-
customId: rawComponent.custom_id,
95-
components: rawComponent.components?.map(c => this.transformComponent(c)),
96-
};
91+
return rawComponent.components
92+
? { type: rawComponent.type, components: rawComponent.components.map(c => this.transformComponent(c)) }
93+
: {
94+
value: rawComponent.value,
95+
type: rawComponent.type,
96+
customId: rawComponent.custom_id,
97+
};
9798
}
9899

99100
/**

packages/discord.js/typings/index.d.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,17 +2228,15 @@ export interface TextInputModalData extends BaseModalData {
22282228

22292229
export interface ActionRowModalData {
22302230
type: ComponentType.ActionRow;
2231-
components: ModalData[];
2231+
components: TextInputModalData[];
22322232
}
22332233

2234-
export type ModalData = TextInputModalData | ActionRowModalData;
2235-
22362234
export class ModalSubmitFields {
22372235
constructor(components: ModalActionRowComponent[][]);
2238-
public components: ActionRow<ModalActionRowComponent>;
2236+
public components: ActionRowModalData[];
22392237
public fields: Collection<string, ModalActionRowComponent>;
2240-
public getField<T extends ComponentType>(customId: string, type: T): { type: T } & ModalData;
2241-
public getField(customId: string, type?: ComponentType): ModalData;
2238+
public getField<T extends ComponentType>(customId: string, type: T): { type: T } & TextInputModalData;
2239+
public getField(customId: string, type?: ComponentType): TextInputModalData;
22422240
public getTextInputValue(customId: string): string;
22432241
}
22442242

0 commit comments

Comments
 (0)