Modals
Create Discord forms and respond to submissions easily.
Example Usage and Modal Handler
Create it inside modals/feedback.ts.
1import { Modal } from 'discordjs-nextgen';23const feedbackModal = Modal.create('feedback_form')4 .title('Feedback')5 .short('name', { label: 'Your name', placeholder: 'Type here...' })6 .paragraph('comment', { label: 'Comment', min: 10, max: 1000 })7 .onSubmit(async (ctx) => {8 const name = ctx.values.name;9 const comment = ctx.values.comment;1011 await ctx.reply({ content: `Thanks ${name}! Your feedback was received.`, ephemeral: true });12 });1314export default feedbackModal;
Showing a Modal
Inside a slash command or button flow, call ctx.showModal().
1await ctx.showModal('feedback_form');
Features
- Chainable Fluent API.
- Built-in validation options.
- Easy onSubmit handling.
- Direct access through ctx.values.