woodendoors7
woodendoors7
DIAdiscord.js - Imagine an app
Created by woodendoors7 on 8/21/2023 in #djs-questions
Mysterious modal error that's got everyone puzzled: Cannot properly serialize component type:
I am using [email protected]. I copied this example from discordjs.guide, and simplified it a bit, though the error happens regardless:
const modal = new ModalBuilder()
.setCustomId('myModal')
.setTitle('My Modal');

const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
.setLabel("What's your favorite color?")
.setStyle(TextInputStyle.Short);

const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
modal.addComponents(firstActionRow);

await interaction.showModal(modal);
const modal = new ModalBuilder()
.setCustomId('myModal')
.setTitle('My Modal');

const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
.setLabel("What's your favorite color?")
.setStyle(TextInputStyle.Short);

const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
modal.addComponents(firstActionRow);

await interaction.showModal(modal);
With this, I get the error Error: Cannot properly serialize component type: undefined, it happens on line modal.addComponents(firstActionRow); This is weird! When I log firstActionRow.components, the component is there fine and dandy, and it's type is 4. I asked in #djs-help-v14, everyone is just as confused as I am! Weird. Does anyone know what's going on?
11 replies