Error Sending Modals

Error: Cannot properly serialize component type: undefined?
11 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
JFK
JFK8mo ago
node 18.17.1
Danial
Danial8mo ago
Send the code and full error please
JFK
JFK8mo ago
Error: Cannot properly serialize component type: undefined
at createComponentBuilder (C:\Users\Administrator\Desktop\Node Projects\BlitzBet\node_modules\@discordjs\builders\dist\index.js:1234:13)
at C:\Users\Administrator\Desktop\Node Projects\BlitzBet\node_modules\@discordjs\builders\dist\index.js:1284:54
at Array.map (<anonymous>)
at new ActionRowBuilder (C:\Users\Administrator\Desktop\Node Projects\BlitzBet\node_modules\@discordjs\builders\dist\index.js:1284:35)
at C:\Users\Administrator\Desktop\Node Projects\BlitzBet\node_modules\@discordjs\builders\dist\index.js:1380:76
at Array.map (<anonymous>)
at ModalBuilder.addComponents (C:\Users\Administrator\Desktop\Node Projects\BlitzBet\node_modules\@discordjs\builders\dist\index.js:1379:37)
at default (file:///C:/Users/Administartor/Desktop/Node%20Projects/BlitzBet/src/listeners/interactions/bets/pickemBet.js:123:9)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async default (file:///C:/Users/Administartor/Desktop/Node%20Projects/BlitzBet/src/listeners/interactions/button.js:18:5)
Error: Cannot properly serialize component type: undefined
at createComponentBuilder (C:\Users\Administrator\Desktop\Node Projects\BlitzBet\node_modules\@discordjs\builders\dist\index.js:1234:13)
at C:\Users\Administrator\Desktop\Node Projects\BlitzBet\node_modules\@discordjs\builders\dist\index.js:1284:54
at Array.map (<anonymous>)
at new ActionRowBuilder (C:\Users\Administrator\Desktop\Node Projects\BlitzBet\node_modules\@discordjs\builders\dist\index.js:1284:35)
at C:\Users\Administrator\Desktop\Node Projects\BlitzBet\node_modules\@discordjs\builders\dist\index.js:1380:76
at Array.map (<anonymous>)
at ModalBuilder.addComponents (C:\Users\Administrator\Desktop\Node Projects\BlitzBet\node_modules\@discordjs\builders\dist\index.js:1379:37)
at default (file:///C:/Users/Administartor/Desktop/Node%20Projects/BlitzBet/src/listeners/interactions/bets/pickemBet.js:123:9)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async default (file:///C:/Users/Administartor/Desktop/Node%20Projects/BlitzBet/src/listeners/interactions/button.js:18:5)
const modal = new ModalBuilder().setCustomId("myModal").setTitle("My Modal");

// Add components to modal

// Create the text input components
const favoriteColorInput = new TextInputBuilder()
.setCustomId("favoriteColorInput")
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle(TextInputStyle.Short);

const hobbiesInput = new TextInputBuilder()
.setCustomId("hobbiesInput")
.setLabel("What's some of your favorite hobbies?")
// Paragraph means multiple lines of text.
.setStyle(TextInputStyle.Paragraph);

// An action row only holds one text input,
// so you need one action row per text input.
let firstActionRow = new ActionRowBuilder();

firstActionRow.addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder().addComponents(hobbiesInput);

// Add inputs to the modal
modal.addComponents(firstActionRow);

// Show the modal to the user
await interaction.showModal(modal);
const modal = new ModalBuilder().setCustomId("myModal").setTitle("My Modal");

// Add components to modal

// Create the text input components
const favoriteColorInput = new TextInputBuilder()
.setCustomId("favoriteColorInput")
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle(TextInputStyle.Short);

const hobbiesInput = new TextInputBuilder()
.setCustomId("hobbiesInput")
.setLabel("What's some of your favorite hobbies?")
// Paragraph means multiple lines of text.
.setStyle(TextInputStyle.Paragraph);

// An action row only holds one text input,
// so you need one action row per text input.
let firstActionRow = new ActionRowBuilder();

firstActionRow.addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder().addComponents(hobbiesInput);

// Add inputs to the modal
modal.addComponents(firstActionRow);

// Show the modal to the user
await interaction.showModal(modal);
Danial
Danial8mo ago
What's at pickemBet.js line 123
JFK
JFK8mo ago
modal.addComponents(firstActionRow); What're you thinking?
Danial
Danial8mo ago
Can you send your package.json?
JFK
JFK8mo ago
{
"name": "proj",
"version": "1.0.0",
"description": "",
"main": "app.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^1.5.1",
"chalk": "^5.3.0",
"discord.js": "^14.13.0",
"dotenv": "^16.3.1",
"mongoose": "^7.6.2"
}
}
{
"name": "proj",
"version": "1.0.0",
"description": "",
"main": "app.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^1.5.1",
"chalk": "^5.3.0",
"discord.js": "^14.13.0",
"dotenv": "^16.3.1",
"mongoose": "^7.6.2"
}
}
Kinda wish this error was more clear honestly, I'm not sure whats undefined
Danial
Danial8mo ago
How are you importing these builders?
JFK
JFK8mo ago
import { ActionRowBuilder, TextInputBuilder } from "@discordjs/builders"; Thats it Good call yupppp Thank you
Danial
Danial8mo ago
Of course