Skip to content
V2 has arrived! A lot has changed, so treat this as a fresh start.

Working with Modals

Modals can be sent when the interaction is a modal-capable interaction - a slash or context command, or a message component interaction.

To send a modal, you can use the interaction.showModal() method. This method takes either a ModalBuilder instance or a raw ModalInteractionResponseCallbackData object.

import { ModalBuilder, LabelBuilder, TextInputStyle } from "honocord";
const modal = new ModalBuilder()
.setCustomId("my-modal")
.setTitle("My Modal")
.addLabelComponents(
new LabelBuilder()
.setLabel("Name")
.setDescription("Enter your name")
.setTextInputComponent((tiBuilder) => tiBuilder.setCustomId("name").setStyle(TextInputStyle.Short).setRequired(true))
);
interaction.showModal(modal);