DiscordAPIError[50035]: Invalid Form Bodydata[BASE_TYPE_REQUIRED]: This field is required

DiscordAPIError[50035]: Invalid Form Body
data[BASE_TYPE_REQUIRED]: This field is required
DiscordAPIError[50035]: Invalid Form Body
data[BASE_TYPE_REQUIRED]: This field is required
trying to show a modal
function popupModal (messageId) {
const popupModal = new ModalBuilder()
.setCustomId('edit-message-'+messageId)
.setTitle('Edit A Bot Message');

const newMessageInput = new TextInputBuilder()
.setCustomId('newMessage')
.setLabel("Enter the new message to replace the old one.")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new ActionRowBuilder().addComponents(newMessageInput);
popupModal.addComponents(firstActionRow);
}

await interaction.showModal(popupModal(interaction.targetId));
function popupModal (messageId) {
const popupModal = new ModalBuilder()
.setCustomId('edit-message-'+messageId)
.setTitle('Edit A Bot Message');

const newMessageInput = new TextInputBuilder()
.setCustomId('newMessage')
.setLabel("Enter the new message to replace the old one.")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new ActionRowBuilder().addComponents(newMessageInput);
popupModal.addComponents(firstActionRow);
}

await interaction.showModal(popupModal(interaction.targetId));
what does this mean? what field and I missing?
3 Replies
d.js toolkit
d.js toolkit2y 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.
skeddles
skeddlesOP2y ago
full error
/edit-bot-message encountered an error: DiscordAPIError[50035]: Invalid Form Body
data[BASE_TYPE_REQUIRED]: This field is required
at SequentialHandler.runRequest (/home/skeddles/pixel-school-bot/node_modules/@discordjs/rest/dist/index.js:933:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (/home/skeddles/pixel-school-bot/node_modules/@discordjs/rest/dist/index.js:712:14)
at async REST.request (/home/skeddles/pixel-school-bot/node_modules/@discordjs/rest/dist/index.js:1321:22)
at async MessageContextMenuCommandInteraction.showModal (/home/skeddles/pixel-school-bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:253:5)
at async Object.execute [as edit-bot-message] (file:///home/skeddles/pixel-school-bot/commands/edit-bot-message.js:12:2)
at async Client.<anonymous> (file:///home/skeddles/pixel-school-bot/commands.js:42:3) {
rawError: {
code: 50035,
errors: { data: [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1098989116571525290/aW50ZXJhY3Rpb246MTA5ODk4OTExNjU3MTUyNTI5MDpjMmI1WFU1WERSNUpsdkU3Rm9SWnQ1bmxuTzJnaHcyOWI5bXk3ekxZVVhyc2oyaVV2MFozeFF1MGZJYjdZMzNNY1J0a3NhNk1xTGVNcHJUMFpFV2tnQ1I1YjRRZmwxeFZjV1pFMEdIcFFZVFRyWXoxM0lza0dPdWtjZHJrUXBSaw/callback',
requestBody: { files: undefined, json: { type: 9, data: undefined } }
}
/edit-bot-message encountered an error: DiscordAPIError[50035]: Invalid Form Body
data[BASE_TYPE_REQUIRED]: This field is required
at SequentialHandler.runRequest (/home/skeddles/pixel-school-bot/node_modules/@discordjs/rest/dist/index.js:933:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (/home/skeddles/pixel-school-bot/node_modules/@discordjs/rest/dist/index.js:712:14)
at async REST.request (/home/skeddles/pixel-school-bot/node_modules/@discordjs/rest/dist/index.js:1321:22)
at async MessageContextMenuCommandInteraction.showModal (/home/skeddles/pixel-school-bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:253:5)
at async Object.execute [as edit-bot-message] (file:///home/skeddles/pixel-school-bot/commands/edit-bot-message.js:12:2)
at async Client.<anonymous> (file:///home/skeddles/pixel-school-bot/commands.js:42:3) {
rawError: {
code: 50035,
errors: { data: [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1098989116571525290/aW50ZXJhY3Rpb246MTA5ODk4OTExNjU3MTUyNTI5MDpjMmI1WFU1WERSNUpsdkU3Rm9SWnQ1bmxuTzJnaHcyOWI5bXk3ekxZVVhyc2oyaVV2MFozeFF1MGZJYjdZMzNNY1J0a3NhNk1xTGVNcHJUMFpFV2tnQ1I1YjRRZmwxeFZjV1pFMEdIcFFZVFRyWXoxM0lza0dPdWtjZHJrUXBSaw/callback',
requestBody: { files: undefined, json: { type: 9, data: undefined } }
}
Syjalo
Syjalo2y ago
Your function doesn't return a modal
Want results from more Discord servers?
Add your server