Modals

In this section, you'll learn how to use the modal message component.

⚠️ Warning: Modals are only supported for interaction responses (like slash commands, buttons, select menus, etc), you can't open a modal from just a message command.

Creating a Modal

$newModal[modalID;title]

  • modalID - Used in $onInteraction[ID] callback. It works same way as buttons and select menus.
  • title - The text which is displayed on top of a modal. This value must be less than or equal to 45 characters.

Adding Input Fields in the Modal

$addTextInput[textInputID;style;label;(minimumLength;maximumLength;required;value;placeholder)]

  • textInputID - ID that is used to retrieve the text input in the field. This value must be unique. (Used in $input[textInputID])

  • style - The text input field style, either short or paragraph.

  • label - Name of the text input field. This value must be less than or equal to 45 characters.

  • minimumLength - Minimum number of characters a user needs to input. This value must be an integer between 0 and 4000, and can't be greater than the maximumLength.

  • maximumLength - Maximum number of characters a user can input. This value must be an integer between 0 and 4000, and can't be less than the minimumLength.

  • required - Whether a user must fill in the text input field, defaults to true.

  • value - The text that is written by default in the text input field. This value must be less than or equal to 4000 characters and must not be less than minimumLength and no more than maximumLength.

  • placeholder - The text that is displayed if the text input field is empty. This value must be less than or equal to 100 characters.

🧙‍♂️ Note: You can't add more than 5 text input fields.

Getting Input from a Modal Submission

Use this function in response to the modal submission interaction:

$input[textInputID]

  • textInputID - The text input field to get the user's input from.

Example

Command Trigger: !modal | Command Code:

$nomention
Modal Example
$addButton[no;bio;Click me!;primary]

Command Trigger: $onInteraction[bio] | Command Code:

$nomention
$newModal[modal;User Bio]
$addTextInput[modalInput1;short;What is your name?;3;30;yes;;Mikołaj]
$addTextInput[modalInput2;short;What are your pronouns?;2;30;yes;;He/Him]
$addTextInput[modalInput3;paragraph;Can you tell us about yourself?;5;1000;no;;I am a Developer]

🤔 Explanation: The code above executes when the button from the previous code gets clicked. So, when the user clicks the button the modal appears.

Command Trigger: $onInteraction[modal] | Command Code:

$nomention
Name : $input[modalInput1]
Pronouns : $input[modalInput2]
About me : $input[modalInput3]

🤔 Explanation: The code above executes when the modal is submitted, because in the previous command we inputted the custom ID 'modal' into the $newModal[] function: $newModal[modal;User Bio].

Result