📋

Modal Builder

Build Discord modal forms with text inputs. Generate code with custom validation, placeholders, and field requirements.

Max 45 characters

Used to identify the modal in your code

Input 1

Feedback Form

10-1000 characters

// Discord.js - Show Modal
const { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder } = require('discord.js');

// Create the modal
const modal = new ModalBuilder()
  .setCustomId('feedback_modal')
  .setTitle('Feedback Form');

// Text Input 1
const feedback_input = new TextInputBuilder()
  .setCustomId('feedback_input')
  .setLabel('What is your feedback?')
  .setStyle(TextInputStyle.Paragraph)
  .setPlaceholder('Enter your feedback here...')
  .setRequired(true)
  .setMinLength(10)
  .setMaxLength(1000);

const row1 = new ActionRowBuilder().addComponents(feedback_input);

// Add inputs to the modal
modal.addComponents(row1);

// Show the modal
await interaction.showModal(modal);
// Discord.js - Handle Modal Submission

client.on('interactionCreate', async (interaction) => {
  if (!interaction.isModalSubmit()) return;
  if (interaction.customId !== 'feedback_modal') return;

  // Get the values from the modal
  const feedback_input = interaction.fields.getTextInputValue('feedback_input');

  // Process the data
  console.log('Modal submitted:');
  console.log('What is your feedback?:', feedback_input);

  // Send response
  await interaction.reply({
    content: 'Thank you for your submission!',
    ephemeral: true
  });
});

💡Quick Tips

  • Modals can have a maximum of 5 text inputs
  • Modal titles are limited to 45 characters
  • Text input values can be up to 4000 characters
  • Modals must be shown in response to an interaction (button, slash command, etc.)
  • You have 15 minutes to respond to a modal submission
  • Custom IDs must be unique within your bot to avoid conflicts
  • Use paragraph style for longer text and short style for single-line inputs

What Are Discord Modals?

Popup forms for collecting user input

Modals are popup forms that appear over Discord's interface, allowing you to collect text input from users. They're perfect for:

📝

Feedback Forms

Collect user feedback and suggestions

🎫

Support Tickets

Create detailed support requests

📋

Application Forms

Accept applications for roles or teams

⚙️

Settings Input

Configure bot settings with forms

📢

Announcements

Create formatted announcements

🎮

Game Actions

Collect player input for game actions

Key Features

  • • Up to 5 text inputs per modal
  • • Short (single-line) or Paragraph (multi-line) input styles
  • • Built-in validation with min/max length
  • • Required and optional fields
  • • Placeholder text and default values
  • • Shown in response to interactions (buttons, commands, etc.)

Text Input Styles

Two types of text inputs for different use cases

📝

Short Style

Single-line text input, perfect for short responses like names, emails, or single-word answers.

Best For

  • • Usernames or names
  • • Email addresses
  • • Short keywords or tags
  • • Numbers or IDs
  • • Single-line responses

Characteristics

  • • Single line of text
  • • Smaller height
  • • Better for quick input
  • • No line breaks allowed

Example Use Case

Label
"What is your Discord username?"
📄

Paragraph Style

Multi-line text input, ideal for longer responses like descriptions, feedback, or detailed explanations.

Best For

  • • Feedback and reviews
  • • Detailed descriptions
  • • Support ticket details
  • • Application responses
  • • Long-form text

Characteristics

  • • Multiple lines of text
  • • Larger height (expandable)
  • • Allows line breaks
  • • Better for detailed input

Example Use Case

Label
"Please describe your issue in detail"

Input Validation

Built-in validation features for text inputs

Required Fields

Mark inputs as required to prevent submission without a value. Required fields show a red asterisk.

📏

Min Length

Set minimum character count (0-4000). Ensures users provide enough detail in their responses.

📐

Max Length

Set maximum character count (1-4000). Prevents overly long responses and spam.

💬

Placeholder Text

Show helpful example text when the input is empty. Guides users on what to enter.

📝

Default Value

Pre-fill inputs with default values. Useful for edit forms or suggesting common responses.

🔖

Custom Labels

Clear, descriptive labels (max 45 chars) help users understand what information to provide.

Common Use Cases

Real-world modal examples for your bot

📝 Feedback Form

Input 1 - Short
Email (optional)
Input 2 - Paragraph
Your Feedback (required, 10-1000 chars)
Input 3 - Paragraph
Suggestions (optional)

🎫 Support Ticket

Input 1 - Short
Issue Summary (required, max 100 chars)
Input 2 - Paragraph
Detailed Description (required, 50-2000 chars)
Input 3 - Paragraph
Steps to Reproduce (optional)

📋 Staff Application

Input 1 - Short
Age (required)
Input 2 - Paragraph
Why do you want to join? (required, 100+ chars)
Input 3 - Paragraph
Previous Experience (required)

📊 Poll Creation

Input 1 - Short
Poll Question (required, max 200 chars)
Input 2 - Paragraph
Options (one per line, required)
Input 3 - Short
Duration (optional, e.g., "1d" or "12h")

Best Practices

Tips for effective modal design

1. Clear Labels

Use descriptive labels that clearly explain what input is expected. Avoid vague labels like "Input" or "Text".

2. Use Placeholders

Provide example text in placeholders to guide users. Example: "e.g., john@example.com" for email fields.

3. Set Appropriate Lengths

Use min/max length validation to ensure quality responses. Don't allow single-character feedback.

4. Choose Right Style

Use Short style for brief answers (name, email) and Paragraph for detailed responses (feedback, descriptions).

5. Limit Required Fields

Only mark essential fields as required. Too many required fields can discourage submissions.

6. Respond Quickly

Always respond to modal submissions within 15 minutes. Send confirmation that you received the input.

7. Unique Custom IDs

Use descriptive, unique custom IDs for modals and inputs to avoid conflicts and make debugging easier.

8. Keep It Simple

Don't use all 5 inputs unless necessary. Shorter forms have higher completion rates.

9. Test Thoroughly

Test your modals with various input lengths and edge cases to ensure validation works correctly.