mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
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
This commit is contained in:
@@ -88,12 +88,13 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|||||||
* @returns {ModalData[]}
|
* @returns {ModalData[]}
|
||||||
*/
|
*/
|
||||||
static transformComponent(rawComponent) {
|
static transformComponent(rawComponent) {
|
||||||
return {
|
return rawComponent.components
|
||||||
value: rawComponent.value,
|
? { type: rawComponent.type, components: rawComponent.components.map(c => this.transformComponent(c)) }
|
||||||
type: rawComponent.type,
|
: {
|
||||||
customId: rawComponent.custom_id,
|
value: rawComponent.value,
|
||||||
components: rawComponent.components?.map(c => this.transformComponent(c)),
|
type: rawComponent.type,
|
||||||
};
|
customId: rawComponent.custom_id,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
10
packages/discord.js/typings/index.d.ts
vendored
10
packages/discord.js/typings/index.d.ts
vendored
@@ -2228,17 +2228,15 @@ export interface TextInputModalData extends BaseModalData {
|
|||||||
|
|
||||||
export interface ActionRowModalData {
|
export interface ActionRowModalData {
|
||||||
type: ComponentType.ActionRow;
|
type: ComponentType.ActionRow;
|
||||||
components: ModalData[];
|
components: TextInputModalData[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ModalData = TextInputModalData | ActionRowModalData;
|
|
||||||
|
|
||||||
export class ModalSubmitFields {
|
export class ModalSubmitFields {
|
||||||
constructor(components: ModalActionRowComponent[][]);
|
constructor(components: ModalActionRowComponent[][]);
|
||||||
public components: ActionRow<ModalActionRowComponent>;
|
public components: ActionRowModalData[];
|
||||||
public fields: Collection<string, ModalActionRowComponent>;
|
public fields: Collection<string, ModalActionRowComponent>;
|
||||||
public getField<T extends ComponentType>(customId: string, type: T): { type: T } & ModalData;
|
public getField<T extends ComponentType>(customId: string, type: T): { type: T } & TextInputModalData;
|
||||||
public getField(customId: string, type?: ComponentType): ModalData;
|
public getField(customId: string, type?: ComponentType): TextInputModalData;
|
||||||
public getTextInputValue(customId: string): string;
|
public getTextInputValue(customId: string): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user