Skip to main content
A form (Discord calls it a modal) is declared with modal(), in any file of src/, and exported. Declare its fields; run receives them under the same names, typed from their kind.
src/components/feedback.ts
A command or a button opens it with interaction.showModal():
src/commands/feedback.ts
That is all: fields.text is a string and fields.rating is 'Good' | 'Okay' | 'Bad'. A form must be the first answer to an interaction; the person then has as long as they want to fill it in.
Every kind of field and the types behind them are in the reference. The interaction of a form is a ModalInteraction.

Fields

A form has 1 to 5 fields, each with a label (45 characters at most) and an optional description. What run receives follows the kind: Every field is required unless it says required: false; a text or a radio that is not required is then string | undefined. min and max say how many can be picked or uploaded; minLength and maxLength how long a text can be.
src/components/report.ts

Opening a form from a button

A button or a menu can open a form too. The form then knows the message of the button (message), and can change it with update() instead of sending a new message:
src/components/rename-button.ts
src/components/rename.ts
data works like the data of a button: given when the form is opened, received typed in run.

What a form holds when it opens

Where you open the form, values fills some fields in advance: a text, the picked options of a menu, radio or checkboxes, or whether a checkbox is checked.
src/components/edit.ts

Where a form is sent from

A form has a where like a command ('guild' by default, 'dm' or 'both'), which decides what run receives about the place. The answers work like the answers of a command: reply(), defer(), edit(), followUp(), delete(), plus update() and deferUpdate() when a button or a menu opened the form. Opening a form from a form is not possible: Discord only opens one in answer to a command or a component.

Embeds and layout

Reuse an embed, and build messages out of texts, sections and containers.

Answering

When to defer, private answers, what the person sees when run fails.