Modal Error

const { SlashCommandBuilder, ActionRowBuilder, Events, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("form")
.setDescription("Description ICI."),

async execute(interaction, client) {
const modal = new ModalBuilder()
.setCustomId('form')
.setTitle('Informations.');

const duree = new TextInputBuilder()
.setCustomId('duree')
.setRequired(true)
.setLabel("La durée du service")
.setPlaceholder('En mois.')
.setStyle(TextInputStyle.Short);

const userid = new TextInputBuilder()
.setCustomId('userid')
.setRequired(true)
.setLabel("Id de l'utilisateur")
.setStyle(TextInputStyle.Short);

const email = new TextInputBuilder()
.setCustomId('email')
.setRequired(true)
.setLabel("email de l'utilisateur")
.setStyle(TextInputStyle.Short);

const type = new TextInputBuilder()
.setCustomId("type")
.setRequired(true)
.setLabel("Type de service")
.setStyle(TextInputStyle.Short);

const vmid = new TextInputBuilder()
.setCustomId("vmid")
.setRequired(true)
.setLabel("ID VM")
.setStyle(TextInputStyle.Short);

const ip = new TextInputBuilder()
.setCustomId("ip")
.setRequired(true)
.setLabel("IP")
.setStyle(TextInputStyle.Short);

const dr = new ActionRowBuilder().addComponents(duree);
const ui = new ActionRowBuilder().addComponents(userid);
const el = new ActionRowBuilder().addComponents(email);
const tp = new ActionRowBuilder().addComponents(type);
const vi = new ActionRowBuilder().addComponents(vmid);
const ipvm = new ActionRowBuilder().addComponents(ip);
modal.addComponents(dr, ui, el, tp, vi, ipvm);

await interaction.showModal(modal);

}
};
const { SlashCommandBuilder, ActionRowBuilder, Events, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("form")
.setDescription("Description ICI."),

async execute(interaction, client) {
const modal = new ModalBuilder()
.setCustomId('form')
.setTitle('Informations.');

const duree = new TextInputBuilder()
.setCustomId('duree')
.setRequired(true)
.setLabel("La durée du service")
.setPlaceholder('En mois.')
.setStyle(TextInputStyle.Short);

const userid = new TextInputBuilder()
.setCustomId('userid')
.setRequired(true)
.setLabel("Id de l'utilisateur")
.setStyle(TextInputStyle.Short);

const email = new TextInputBuilder()
.setCustomId('email')
.setRequired(true)
.setLabel("email de l'utilisateur")
.setStyle(TextInputStyle.Short);

const type = new TextInputBuilder()
.setCustomId("type")
.setRequired(true)
.setLabel("Type de service")
.setStyle(TextInputStyle.Short);

const vmid = new TextInputBuilder()
.setCustomId("vmid")
.setRequired(true)
.setLabel("ID VM")
.setStyle(TextInputStyle.Short);

const ip = new TextInputBuilder()
.setCustomId("ip")
.setRequired(true)
.setLabel("IP")
.setStyle(TextInputStyle.Short);

const dr = new ActionRowBuilder().addComponents(duree);
const ui = new ActionRowBuilder().addComponents(userid);
const el = new ActionRowBuilder().addComponents(email);
const tp = new ActionRowBuilder().addComponents(type);
const vi = new ActionRowBuilder().addComponents(vmid);
const ipvm = new ActionRowBuilder().addComponents(ip);
modal.addComponents(dr, ui, el, tp, vi, ipvm);

await interaction.showModal(modal);

}
};
Error :
/home/container/node_modules/@discordjs/rest/dist/index.js:640
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[50035]: Invalid Form Body
data.components[BASE_TYPE_BAD_LENGTH]: Must be between 1 and 5 in length.
at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:640:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async BurstHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:736:23)
at async REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1387:22)
at async ChatInputCommandInteraction.showModal (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:253:5)
at async Object.execute (/home/container/src/commands/Bot/form.js:58:3) {
requestBody: {
files: undefined,
json: {
type: 9,
data: {
custom_id: 'form',
title: 'Informations.',
components: [
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] }
]
}
}
},
rawError: {
code: 50035,
errors: {
data: { components: { _errors: [ [Object] ] } }
},
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'POST',
/home/container/node_modules/@discordjs/rest/dist/index.js:640
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[50035]: Invalid Form Body
data.components[BASE_TYPE_BAD_LENGTH]: Must be between 1 and 5 in length.
at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:640:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async BurstHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:736:23)
at async REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1387:22)
at async ChatInputCommandInteraction.showModal (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:253:5)
at async Object.execute (/home/container/src/commands/Bot/form.js:58:3) {
requestBody: {
files: undefined,
json: {
type: 9,
data: {
custom_id: 'form',
title: 'Informations.',
components: [
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] }
]
}
}
},
rawError: {
code: 50035,
errors: {
data: { components: { _errors: [ [Object] ] } }
},
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'POST',
3 Replies
d.js toolkit
d.js toolkit15mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
monbrey
monbrey15mo ago
max 5 you have 6
Welltag
Welltag15mo ago
ohhh ok thanks you
Want results from more Discord servers?
Add your server