#What is the code structure for Modals
1 messages · Page 1 of 1 (latest)
Is it text input style or styles
TextInputStyles.PARAGRAPH
nope still doesnt work
same error
^
TypeError: Cannot read properties of undefined (reading 'PARAGRAPH')```
well did you import it properly
Client,
Intents,
MessageActionRow,
MessageButton, Modal, TextInputStyles, TextInputComponent
} = require('discord.js');```
one sec have to install it myself first
okay progress has been made
DiscordAPIError: Invalid Form Body
data.components[0]: The specified component type is invalid in this context```
httpStatus: 400,
requestData: {
json: {
type: 9,
data: {
components: [
{
custom_id: 'text',
label: 'Enter text',
max_length: null,
min_length: null,
placeholder: null,
required: false,
style: 2,
type: 4,
value: null
}
],
custom_id: 'testing',
title: 'Test modal!'
}
},
files: []
}
}```
looks like .addComponents() takes ActionRows with TextInputComponent
so need to create an action row then?
const modal = new Modal().setTitle("Test modal!").setCustomId("testing").addComponents(new ActionRow().addComponents([new TextInputComponent().setCustomId("text").setLabel("Enter text").setStyle('PARAGRAPH')])) like this?
ActionRow is not a constructor
sorry, in v13 its still MessageActionRow
thanks
It worked!!
Is there a way to add text inside it
as in not an input field but description
not that I know
isModalSubmission()
you didn't reply, yes
validation in what form
Checking length, it contains certain text etc
you can set the min and max length of the text
ahh okay
discord displays an error
but thats about it?
kk thanks
can i ask how you handle the input data
this is how I do it
You basically get a field value by using interaction.fields.getTextInputValue(id)