-
Notifications
You must be signed in to change notification settings - Fork 1
/
modal.js
33 lines (27 loc) · 917 Bytes
/
modal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } from 'discord.js';
export const createModal = async (
title,
customId,
textInputValue,
textInputLabel,
textInputPlaceholder,
textInputCustomId
) => {
// Create the modal
const modal = new ModalBuilder().setCustomId(customId).setTitle(title);
// Add components to modal
const paragraphInput = new TextInputBuilder()
.setCustomId(textInputCustomId)
.setLabel(textInputLabel)
.setValue(textInputValue)
.setPlaceholder(textInputPlaceholder)
.setMaxLength(1000)
// Paragraph means multiple lines of text.
.setStyle(TextInputStyle.Paragraph);
// An action row only holds one text input,
// so you need one action row per text input.
const actionRow = new ActionRowBuilder().addComponents(paragraphInput);
// Add inputs to the modal
modal.addComponents(actionRow);
return modal;
};