require('dotenv').config(); const { Client, GatewayIntentBits, ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ModalSubmitFields, ModalSubmitInteraction } = require('discord.js'); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, ], }); const prefix = '!'; client.on('ready', () => { console.log(`${client.user.tag} is online`); }); client.on('messageCreate', async (message) => { if (message.author.bot || !message.content.toLowerCase().startsWith(prefix)) { return; } const args = message.content.slice(prefix.length).trim().split(/ +/); const command = args.shift().toLowerCase(); if (command === 'ping') { message.reply('I hear you, PONG!'); } if (command === 'createitem') { const modal = new ModalBuilder({ type: 1, customId: `${message.author.id}`, title: 'Create Item Modal', }); const itemNameInput = new TextInputBuilder({ customId: 'itemNameInput', label: 'What is the item name?', style: TextInputStyle.Short, }); const itemDescInput = new TextInputBuilder({ customId: 'itemDescInput', label: 'What is the item description?', style: TextInputStyle.Paragraph, }); const firstActionRow = new ActionRowBuilder().addComponents(itemNameInput); const secondActionRow = new ActionRowBuilder().addComponents(itemDescInput); modal.addComponents(firstActionRow, secondActionRow); try { await message.reply({ content: 'Please provide the item details:', components: [modal], }); } catch (error) { console.error('Error showing the modal:', error); } } }); client.on('interactionCreate', async (interaction) => { if (!interaction.isModalSubmit()) return; if (interaction.customId === 'itemNameInput' || interaction.customId === 'itemDescInput') { const submittedValue = interaction.fields.getTextInputValue(interaction.customId); await interaction.followUp(`Received: ${interaction.customId} - ${submittedValue}`); // Here, you can handle storing the submitted values in a database } }); client.login(process.env.TOKEN); This is the error console.Log: [nodemon] starting `node bot/index.js` TTRPGBOT#9189 is online Error showing the modal: DiscordAPIError[50035]: Invalid Form Body components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,). at handleErrors (C:\Users\Owner\Desktop\SiksRepos\Projects\TTRPG-Inventory-Bot\node_modules\@discordjs\rest\dist\index.js:722:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async SequentialHandler.runRequest (C:\Users\Owner\Desktop\SiksRepos\Projects\TTRPG-Inventory-Bot\node_modules\@discordjs\rest\dist\index.js:1120:23) at async SequentialHandler.queueRequest (C:\Users\Owner\Desktop\SiksRepos\Projects\TTRPG-Inventory-Bot\node_modules\@discordjs\rest\dist\index.js:953:14) at async _REST.request (C:\Users\Owner\Desktop\SiksRepos\Projects\TTRPG-Inventory-Bot\node_modules\@discordjs\rest\dist\index.js:1266:22) at async TextChannel.send (C:\Users\Owner\Desktop\SiksRepos\Projects\TTRPG-Inventory-Bot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:155:15) at async Client. (C:\Users\Owner\Desktop\SiksRepos\Projects\TTRPG-Inventory-Bot\bot\index.js:56:7) { requestBody: { files: [], json: { content: 'Please provide the item details:', tts: false, nonce: undefined, embeds: undefined, components: [Array], username: undefined, avatar_url: undefined, allowed_mentions: undefined, flags: undefined, message_reference: [Object], attachments: undefined, sticker_ids: undefined, thread_name: undefined } }, rawError: { message: 'Invalid Form Body', code: 50035, errors: { components: [Object] } }, code: 50035, status: 400, method: 'POST', url: 'https://discord.com/api/v10/channels/1178903212300976218/messages' }