Custom Commands docsCustom CommandsDocs

Search docs

Find a page, function or guide

HomeSupportDashboard

Getting started

  • Introduction
  • Your first command
  • How a command runs
  • Variables in replies
  • Text commands
  • Events
  • Using Slushy

Guides

  • Welcome messages
  • Role menus
  • Auto moderation
  • Social alerts
  • Moderation commands
  • Levels and XP
  • Economy and coins
  • Ticket system
  • Giveaways
  • Poll
  • Button game
  • Reminders

Concepts

  • Buttons and menus
  • Forms
  • Saving data
  • Permissions and cooldowns
  • Limits and premium
  • Common mistakes

API reference

  • Response
  • Messages
  • Embeds
  • Members and roles
  • Channels
  • Storage
  • Checks
  • Views
  • Components
  • Modals
  • Interactions
  • Paginators
  • Web and files
  • Scheduling
  • Server events and polls
  • Time
  • Waiting
  • Utilities
  • Objects
  • Event variables

Examples

  • /8ball
  • /coinflip
  • /avatar
  • /serverinfo
  • /rank
  • /remind

API reference

View .md

Modals

Open a pop-up form, then read what the member typed.

A modal is a pop-up form in Discord. It has a title and up to 5 text boxes. You open it in answer to a command or a click. When the member presses Submit, a Modal Submit event runs with what they typed.

For a walk-through, read Forms.

ModalBuilder#

Makes an empty form.

python
form = ModalBuilder(title, custom_id)
ArgumentWhat it does
titleThe text at the top of the form.
custom_idThe name the submit carries. Your Modal Submit event listens for it.

add_text_input#

Adds a text box. Each box gets its own row.

python
form.add_text_input(
    name,
    label,
    style="short",
    placeholder=...,
    value=...,
    required=True,
    min_length=0,
    max_length=4000,
)
ArgumentWhat it does
nameThe key for this box in values.
labelThe text above the box.
style"short": one line. "long": a big box for many lines.
placeholderGrey hint text in the empty box.
valueText already filled in.
requiredFalse lets the member leave it empty.
min_length, max_lengthThe shortest and longest answer allowed.

send_modal#

Opens the form. Needs await.

python
await send_modal(form)               # from a command or a component handler
await send_modal(form, interaction)  # from a View button or menu

Opening the form is the answer to the command or click. Do not defer before it.

Slash commands: turn off Show thinking

A slash command answers Discord at once when Show "thinking…" is on. Then a form can no longer open. Turn it off under Behavior on the command.

Inside a View

Pass the click as the second argument: send_modal(form, interaction). With one argument the form answers the command, which is already answered, and Discord refuses it.

Example: a feedback command

python
# pre-hook of /feedback, with Show "thinking…" turned off
form = ModalBuilder(title="Send feedback", custom_id="feedback-form")
form.add_text_input("topic", "Topic", placeholder="Bug, idea, other…")
form.add_text_input("details", "Tell us more", style="long", max_length=1000)
await send_modal(form)

values#

In a Modal Submit event, values is a dictionary. Each key is a box name. Each value is what the member typed.

python
# Modal Submit event, custom ID: feedback-form
await defer_response(ephemeral=True)
send_message("feedback", f"**{values['topic']}** from {user.mention}\n{values['details']}")
await respond_interaction(interaction, "Thanks! We got your feedback.")

An empty optional box gives "".

get_modal_values#

Reads the answers from a submit, as the same dictionary as values.

python
get_modal_values(interaction)

You only need it when you have a submit outside a Modal Submit event, for example one you got from wait_for("modal_submit").

PreviousComponentsNext Interactions

On this page

  • ModalBuilder
  • add_text_input
  • send_modal
  • values
  • get_modal_values
Custom CommandsCustom Commands

The #1 Custom Commands Discord bot — build commands, events and databases with zero boilerplate.

Join the support server

Product

  • Overview
  • Why us?
  • Premium
  • Template shop

Features

  • AI Agent
  • Reaction roles
  • Welcome messages
  • Embed builder
  • Social alerts
  • Custom bot

Resources

  • Docs
  • Blog
  • Support
  • Dashboard

Company

  • Privacy
  • Terms
  • Contact
contact@ccbot.app

2 Frederick Street, London, WC1X 0ND

Payments secured by Stripe

© WEiRDSOFT LTD. All rights reserved.

Custom Commands