Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types(ModalSubmitFields): components is an array #9406

Merged
merged 3 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/discord.js/src/structures/ModalSubmitInteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ class ModalSubmitInteraction extends BaseInteraction {
* @returns {ModalData[]}
Jiralite marked this conversation as resolved.
Show resolved Hide resolved
*/
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,
};
}

/**
Expand Down
10 changes: 4 additions & 6 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2217,17 +2217,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<ModalActionRowComponent>;
public components: ActionRowModalData[];
public fields: Collection<string, ModalActionRowComponent>;
public getField<T extends ComponentType>(customId: string, type: T): { type: T } & ModalData;
public getField(customId: string, type?: ComponentType): ModalData;
public getField<T extends ComponentType>(customId: string, type: T): { type: T } & TextInputModalData;
public getField(customId: string, type?: ComponentType): TextInputModalData;
public getTextInputValue(customId: string): string;
}

Expand Down