Skip to content

$interactionModal

$interactionModal create an user interactive modal.

Usage

$interactionModal[title;customID;components]

Parameters

FieldTypeDescriptionRequired
titlestringThe title of the modal which will be displayed as Modal Header.true
customIDstringThe component custom ID.true
componentsstringThe modal text components.true

Example(s)

This will create a button and modal which will send the entered data to the same channel and give an ephemeral response to the user who submitted the form:

Please note that you require “events: [“onMessage”, “onInteractionCreate”]” in your main file (also known as, in most cases, index.js)

1
client.command({
2
name: "interactionModal",
3
code: `
4
$addButton[1;Press Me!;primary;exampleID;false]
5
Pretty Example!`
6
}); // Create a button which will trigger the modal.
7
8
module.exports = [
9
{
10
name: "exampleID",
11
type: "interaction",
12
prototype: "button", // Using "prototype" as this interaction belongs to a button.
13
code: `
14
$interactionModal[Example!;customID;
15
{actionRow:
16
{textInput:What's your name?:1:nameInput:true:Your pretty name!:2:200}
17
}
18
{actionRow:
19
{textInput:What's your age?:1:ageInput:true:You young soul!:1:3}
20
}
21
{actionRow:
22
{textInput:What's your gender?:2:genderInput:true:Anything will work!:1:10}
23
}
24
]`
25
}
26
]; /* The modal itself, we use {textInput} to accept user input.
27
28
The correct usage of {textInput} would be:
29
30
{textInput:title:type (1 : small text field, 2 : big text field):customID:required ( true, false ):placeholder:minVal:maxVal}
31
32
*/
33
34
module.exports = [
35
{
36
name: "customID",
37
type: "interaction",
38
prototype: "modal", // Using "prototype" as this interaction belongs to a modal.
39
code: `
40
$interactionReply[Thanks for submitting this form!;everyone;true]
41
42
$title[$username submitted a form!;$userAvatar]
43
$addField[Their name is..;$textInputValue[nameInput]]
44
$addField[Their age is..;$textInputValue[ageInput]]
45
$addField[Their gender is..;$textInputValue[genderInput]]`
46
}
47
]; /* Will return the values entered earlier from the modal. Using $textInputValue to retrieve those.
48
49
Alternatively you could use $channelSendMessage[channelID;content] to send the data to another channel.
50
$channelSendMessage[$channelID;{newEmbed:{title:$username submitted a form!:$userAvatar}{field:Their name is..:$textInputValue[nameInput]}{field:Their age is..:$textInputValue[ageInput]}{field:Their gender is..:$textInputValue[genderInput]}}]
51
*/