hey iam builduin a ticket system for my bot with slash command and deploy command buti hav an error

it works fine and it shows the slash command in discord but when i execute it it says this error Error opening ticket: DiscordAPIError[50035]: Invalid Form Body name[BASE_TYPE_REQUIRED]: This field is required pls help me i dk how to fix it
13 Replies
d.js toolkit
d.js toolkit5mo 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!
xx_lavaboy_xx123
show code
Kriari_
Kriari_5mo ago
const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('openticket') .setDescription('Open a support ticket'), async execute(interaction) { await interaction.deferReply({ ephemeral: true }); try { const ticketCategory = interaction.guild.channels.cache.find( (category) => category.type === 'GUILD_CATEGORY' && category.name === 'tickets' ); if (!ticketCategory) { const createdCategory = await interaction.guild.channels.create('tickets', { type: 'GUILD_CATEGORY', }); const ticketCategoryId = createdCategory.id; console.log(Ticket category created with ID: ${ticketCategoryId}); } const channelName = ticket-${interaction.user.id}; const ticketChannel = await interaction.guild.channels.create(channelName, { name: channelName, type: 'GUILD_TEXT', parent: ticketCategory, }); console.log('Channel Name:', channelName); console.log('Ticket Category:', ticketCategory); await ticketChannel.send(Welcome to your ticket, ${interaction.user}!); await interaction.editReply({ content: 'Ticket opened successfully! Check your DMs for more information.', }); const closeButton = { type: 2, style: 4, custom_id: 'close_ticket', }; await interaction.user.send({ content: 'Your ticket has been opened!', components: [ { type: 1, components: [closeButton], }, ], }); } catch (error) { console.error('Error opening ticket:', error); await interaction.followUp({ content: 'An error occurred while opening the ticket.', ephemeral: true }); } }, };
xx_lavaboy_xx123
are u using v14 or v13? do npm ls discord.js in ur terminal
Kriari_
Kriari_5mo ago
discord.js@14.14.1
xx_lavaboy_xx123
the issue thats causing the error is <GuildChannelManager>.create() takes GuildChannelCreateOptions as the first parameter, not a string also v14 uses PascalCase for enums not snake_case, so for example u have to replace GUILD_CATEGORY with GuildCategory etc
Kriari_
Kriari_5mo ago
so everwhere that i have GUILD_CATEGORY i change it to GuildCategory so how do fix that and also GUILD_TEXT is GuildText??
xx_lavaboy_xx123
yes read the updating guide https://discordjs.guide/additional-info/changes-in-v14.html#enum-values there's an example of how to use this method in the docs i linked
Kriari_
Kriari_5mo ago
hold on on what category is the example ?
Kriari_
Kriari_5mo ago
ok i will try it np still an error const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('openticket') .setDescription('Open a support ticket'), async execute(interaction) { await interaction.deferReply({ ephemeral: true }); try { // Generate a unique channel name for the ticket const channelName = ticket-${interaction.user.id}; // Check if the ticket category exists, create it if not let ticketCategory = interaction.guild.channels.cache.find( (category) => category.type === 'GUILD_CATEGORY' && category.name === 'tickets' ); if (!ticketCategory) { ticketCategory = await interaction.guild.channels.create('tickets', { type: 'GUILD_CATEGORY', }); console.log(Ticket category created with ID: ${ticketCategory.id}); } // Create the ticket channel guild.channels.create({ name: ticket of ${interaction.user.id}, reason: 'create a ticket'}) .then(console.log) .catch(console.error); console.log('Channel Name:', channelName); console.log('Ticket Channel:', ticketChannel); // Send a welcome message in the ticket channel await ticketChannel.send(Welcome to your ticket, ${interaction.user}!); // Reply to the user in the interaction await interaction.editReply({ content: 'Ticket opened successfully! Check your DMs for more information.', }); // Send a message to the user with a close button const closeButton = { type: 2, style: 4, custom_id: 'close_ticket', }; await interaction.user.send({ content: 'Your ticket has been opened!', components: [ { type: 1, components: [closeButton], }, ], }); } catch (error) { console.error('Error opening ticket:', error); console.log('Full error object:', error); await interaction.followUp({ content: 'An error occurred while opening the ticket.', ephemeral: true }); } }, }; here is the code and Full error object: DiscordAPIError[50035]: Invalid Form Body name[BASE_TYPE_REQUIRED]: This field is required at handleErrors (C:\Users\oikon\Desktop\Yo 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\oikon\Desktop\Yo Bot\node_modules@discordjs\rest\dist\index.js:1120:23) at async SequentialHandler.queueRequest (C:\Users\oikon\Desktop\Yo Bot\node_modules@discordjs\rest\dist\index.js:953:14) at async _REST.request (C:\Users\oikon\Desktop\Yo Bot\node_modules@discordjs\rest\dist\index.js:1266:22) at async GuildChannelManager.create (C:\Users\oikon\Desktop\Yo Bot\node_modules\discord.js\src\managers\GuildChannelManager.js:171:18) at async Object.execute (C:\Users\oikon\Desktop\Yo Bot\commands\utility\ticketCommand.js:20:26) at async Client.<anonymous> (C:\Users\oikon\Desktop\Yo Bot\index.js:48:3) { requestBody: { thats the error wait so how do i do it in pascalCase is snake case wrong ? ok hold on const { SlashCommandBuilder, MessageActionRow, MessageButton } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('openticket') .setDescription('Open a support ticket'), async execute(interaction) { await interaction.deferReply({ ephemeral: true }); try { // Find or create a ticket category const ticketCategory = interaction.guild.channels.cache.find( (category) => category.type === 'GuildCategory' && category.name === 'tickets' ) || await interaction.guild.channels.create('tickets', { type: 'GuildCategory' }); // Create a text channel for the ticket const ticketChannel = await interaction.guild.channels.create(ticket-${interaction.user.id}, { type: 'GUILD_TEXT', parent: ticketCategory.id, permissionOverwrites: [ { id: interaction.user.id, allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], }, { id: interaction.guild.roles.everyone, deny: ['VIEW_CHANNEL'], }, ], }); // Example: Create a button to close the ticket const closeButton = new MessageButton() .setCustomId('close_ticket') .setLabel('Close Ticket') .setStyle('DANGER'); // Example: Create an action row with the close button const row = new MessageActionRow().addComponents(closeButton); // Example: Send a ticket message with an embed await ticketChannel.send({ content: Welcome to your ticket, ${interaction.user}!, embeds: [createTicketEmbed()], }); await interaction.editReply({ content: 'Ticket opened successfully! Check your DMs for more information.', }); // Notify the user in DMs await interaction.user.send({ content: 'Your ticket has been opened!', components: [row], }); } catch (error) { console.error('Error opening ticket:', error); await interaction.followUp({ content: 'An error occurred while opening the ticket.', ephemeral: true }); } }, }; function createTicketEmbed() { // Example: Create and return a simple ticket embed return { title: 'Support Ticket', description: 'Please describe your issue, and our support team will assist you shortly.', color: 0x3498db, }; } here is my new code still got tha same issue ummm yeahh i mean i am new to disc.js and every tutorial i see i think its wrong but probably i do it wrong because i am preety trash so yeah i dont know how to code a ticket system and i ask chatgpt and it cant fix this one error
d.js docs
d.js docs5mo ago
guide Home: Introduction read more
Kriari_
Kriari_5mo ago
yeah i used dj docs to create my firt three slash commands but i wanted to create a ticket system with slash commands