modal
modal<
F>(config,run):Modal<F>
Defined in: modal.ts:22
Declares a modal: a form Discord shows in a popup. Open it with c.modal() from a command or a
button, and add it to the modals of bot so the bot gets what the user typed.
Type Parameters
Section titled “Type Parameters”F extends Fields
Parameters
Section titled “Parameters”config
Section titled “config”What Discord shows in the popup.
fields
Section titled “fields”F
The text fields, keyed by name. A field is required unless required is false.
string
The id Discord sends back when the user submits the form.
string
The title of the popup.
(c) => Response | Promise<Response>
Answers the submitted form. c.fields holds the text of each field, keyed by name.
A field that is not required and left empty is undefined.
To carry a value through the form, open it with c.modal(form, value). The handler gets that
value as c.value, such as the id of the item the form edits.
Returns
Section titled “Returns”Modal<F>
The modal, for c.modal() and the modals of bot.
Example
Section titled “Example”const feedback = modal( { id: 'feedback', title: 'Feedback', fields: { text: { label: 'Your idea', style: 'paragraph' } } }, (c) => c.reply(`Thanks: ${c.fields.text}`),);