ModalBuilder() is not working !
else if (interaction.commandName === "userregister") {
console.log('hello world register !');
const modal = new ModalBuilder()
.setTitle("Register User Form")
.setCustomId('registerUserModal')
.setComponents(
new ActionRowBuilder().setComponents(
new TextInputBuilder()
.setLabel('username')
.setCustomId('username')
.setStyle(TextInputStyle.Short)
)
);
interaction.showModal(modal);
else if (interaction.commandName === "userregister") {
console.log('hello world register !');
const modal = new ModalBuilder()
.setTitle("Register User Form")
.setCustomId('registerUserModal')
.setComponents(
new ActionRowBuilder().setComponents(
new TextInputBuilder()
.setLabel('username')
.setCustomId('username')
.setStyle(TextInputStyle.Short)
)
);
interaction.showModal(modal);
file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:465
return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedPropertyError(errors));
^
CombinedPropertyError: Received one or more errors
at ArrayValidator.handle (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:465:70)
at ArrayValidator.parse (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:204:88)
at validateRequiredParameters (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1232:23)
at ModalBuilder.toJSON (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1299:5)
at ChatInputCommandInteraction.showModal (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:256:46)
at Client.<anonymous> (file:///C:/Users/kura/Desktop/slash_tutorial/src/index.js:56:25)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\client\websocket\WebSocketManager.js:354:31) {
errors: [
[
0,
ExpectedValidationError: Expected
at InstanceValidator.handle (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:722:75)
at InstanceValidator.run (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:190:23)
at ArrayValidator.handle (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:459:37)
at ArrayValidator.parse (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:204:88)
at validateRequiredParameters (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1232:23)
at ModalBuilder.toJSON (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1299:5)
at ChatInputCommandInteraction.showModal (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:256:46)
at Client.<anonymous> (file:///C:/Users/kura/Desktop/slash_tutorial/src/index.js:56:25)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12) {
validator: 's.instance(V)',
given: ActionRowBuilder {
data: { type: 1 },
components: [ [TextInputBuilder] ]
},
expected: [class ActionRowBuilder extends ComponentBuilder]
}
]
]
}
Node.js v18.16.0
[nodemon] app crashed - waiting for file changes before starting...
file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:465
return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedPropertyError(errors));
^
CombinedPropertyError: Received one or more errors
at ArrayValidator.handle (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:465:70)
at ArrayValidator.parse (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:204:88)
at validateRequiredParameters (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1232:23)
at ModalBuilder.toJSON (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1299:5)
at ChatInputCommandInteraction.showModal (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:256:46)
at Client.<anonymous> (file:///C:/Users/kura/Desktop/slash_tutorial/src/index.js:56:25)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\client\websocket\WebSocketManager.js:354:31) {
errors: [
[
0,
ExpectedValidationError: Expected
at InstanceValidator.handle (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:722:75)
at InstanceValidator.run (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:190:23)
at ArrayValidator.handle (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:459:37)
at ArrayValidator.parse (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@sapphire/shapeshift/dist/index.mjs:204:88)
at validateRequiredParameters (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1232:23)
at ModalBuilder.toJSON (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1299:5)
at ChatInputCommandInteraction.showModal (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:256:46)
at Client.<anonymous> (file:///C:/Users/kura/Desktop/slash_tutorial/src/index.js:56:25)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12) {
validator: 's.instance(V)',
given: ActionRowBuilder {
data: { type: 1 },
components: [ [TextInputBuilder] ]
},
expected: [class ActionRowBuilder extends ComponentBuilder]
}
]
]
}
Node.js v18.16.0
[nodemon] app crashed - waiting for file changes before starting...
2 Replies
• 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.import { Client, GatewayIntentBits, Routes, ActionRowBuilder, TextInputStyle } from 'discord.js';
import { SelectMenuBuilder, ModalBuilder, TextInputBuilder} from '@discordjs/builders'
import { REST } from '@discordjs/rest';
import OrderCommand from './commands/order.js';
import RolesCommand from './commands/roles.js';
import UsersCommand from './commands/user.js';
import ChannelsCommand from './commands/channels.js';
import BanCommand from './commands/ban.js';
import RegisterCommand from './commands/user_register.js';
import { Client, GatewayIntentBits, Routes, ActionRowBuilder, TextInputStyle } from 'discord.js';
import { SelectMenuBuilder, ModalBuilder, TextInputBuilder} from '@discordjs/builders'
import { REST } from '@discordjs/rest';
import OrderCommand from './commands/order.js';
import RolesCommand from './commands/roles.js';
import UsersCommand from './commands/user.js';
import ChannelsCommand from './commands/channels.js';
import BanCommand from './commands/ban.js';
import RegisterCommand from './commands/user_register.js';
if (interaction.commandName === "userregister") {
console.log('hello world register !');
// Create the 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.
const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder().addComponents(hobbiesInput);
// Add inputs to the modal
modal.addComponents(firstActionRow, secondActionRow);
await interaction.showModal(modal);
if (interaction.commandName === "userregister") {
console.log('hello world register !');
// Create the 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.
const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder().addComponents(hobbiesInput);
// Add inputs to the modal
modal.addComponents(firstActionRow, secondActionRow);
await interaction.showModal(modal);
node:events:491
throw er; // Unhandled 'error' event
^
Error: Cannot properly serialize component type: undefined
at createComponentBuilder (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1140:13)
at file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1187:54
at Array.map (<anonymous>)
at new ActionRowBuilder (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1187:35)
at file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1281:76
at Array.map (<anonymous>)
at ModalBuilder.addComponents (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1280:37)
at Client.<anonymous> (file:///C:/Users/kura/Desktop/slash_tutorial/src/index.js:73:19)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
Node.js v18.16.0
[nodemon] app crashed - waiting for file changes before starting...
node:events:491
throw er; // Unhandled 'error' event
^
Error: Cannot properly serialize component type: undefined
at createComponentBuilder (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1140:13)
at file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1187:54
at Array.map (<anonymous>)
at new ActionRowBuilder (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1187:35)
at file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1281:76
at Array.map (<anonymous>)
at ModalBuilder.addComponents (file:///C:/Users/kura/Desktop/slash_tutorial/node_modules/@discordjs/builders/dist/index.mjs:1280:37)
at Client.<anonymous> (file:///C:/Users/kura/Desktop/slash_tutorial/src/index.js:73:19)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\kura\Desktop\slash_tutorial\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
Node.js v18.16.0
[nodemon] app crashed - waiting for file changes before starting...