DiscordAPIError[50035]: Invalid Form Bodyname[BASE_TYPE_REQUIRED]: This field is required
// createTicket.js
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageActionRow, MessageButton, MessageEmbed } = require('discord.js');
let ticketNumber = 0;
module.exports = {
data: new SlashCommandBuilder()
.setName('create_ticket')
.setDescription('Create a support ticket'),
run: async ({ interaction, client }) => {
// Increment the ticket number
ticketNumber++;
const channel = await interaction.guild.channels.create(
ticket-${String(ticketNumber).padStart(4, '0')}
, {
type: 'GUILD_TEXT',
permissionOverwrites: [
{
id: interaction.user.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
},
{
id: interaction.guild.roles.everyone,
deny: ['VIEW_CHANNEL'],
},
],
});
const embed = new EmbedBuilder()
.setTitle('New Ticket')
.setDescription('Thanks for creating your ticket. Please describe your issue in detail.')
.setColor(0x00FF00);
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('close_ticket')
.setLabel('Close Ticket')
.setStyle(ButtonStyle.Danger),
);
await channel.send({ content: ${interaction.user}
, embeds: [embed], components: [row] });
await interaction.reply({ content: Your ticket has been created: <#${channel.id}>
, ephemeral: true });
},
};10 Replies
- 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 staffFull error : node:events:491
throw er; // Unhandled 'error' event
^
DiscordAPIError[50035]: Invalid Form Body
name[BASE_TYPE_REQUIRED]: This field is required
at handleErrors (C:\Users\abhin\OneDrive\Desktop\CaterRed\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\abhin\OneDrive\Desktop\CaterRed\node_modules@discordjs\rest\dist\index.js:1120:23)
at async SequentialHandler.queueRequest (C:\Users\abhin\OneDrive\Desktop\CaterRed\node_modules@discordjs\rest\dist\index.js:953:14)
at async _REST.request (C:\Users\abhin\OneDrive\Desktop\CaterRed\node_modules@discordjs\rest\dist\index.js:1266:22) at async GuildChannelManager.create (C:\Users\abhin\OneDrive\Desktop\CaterRed\node_modules\discord.js\src\managers\GuildChannelManager.js:171:18) at async Object.run (C:\Users\abhin\OneDrive\Desktop\CaterRed\commands\Ticket\createTicket.js:15:25) at async Client.<anonymous> (C:\Users\abhin\OneDrive\Desktop\CaterRed\node_modules\commandkit\dist\index.js:643:7) Emitted 'error' event on Client instance at: at emitUnhandledRejectionOrErr (node:events:394:10) at process.processTicksAndRejections (node:internal/process/task_queues:84:21) { requestBody: { files: undefined, json: { name: undefined, topic: undefined, type: undefined, nsfw: undefined, bitrate: undefined, user_limit: undefined, parent_id: undefined, position: undefined, permission_overwrites: undefined, rate_limit_per_user: undefined, rtc_region: undefined, video_quality_mode: undefined, default_thread_rate_limit_per_user: undefined, available_tags: undefined, default_reaction_emoji: undefined, default_auto_archive_duration: undefined, default_sort_order: undefined, default_forum_layout: undefined } },
at async SequentialHandler.queueRequest (C:\Users\abhin\OneDrive\Desktop\CaterRed\node_modules@discordjs\rest\dist\index.js:953:14)
at async _REST.request (C:\Users\abhin\OneDrive\Desktop\CaterRed\node_modules@discordjs\rest\dist\index.js:1266:22) at async GuildChannelManager.create (C:\Users\abhin\OneDrive\Desktop\CaterRed\node_modules\discord.js\src\managers\GuildChannelManager.js:171:18) at async Object.run (C:\Users\abhin\OneDrive\Desktop\CaterRed\commands\Ticket\createTicket.js:15:25) at async Client.<anonymous> (C:\Users\abhin\OneDrive\Desktop\CaterRed\node_modules\commandkit\dist\index.js:643:7) Emitted 'error' event on Client instance at: at emitUnhandledRejectionOrErr (node:events:394:10) at process.processTicksAndRejections (node:internal/process/task_queues:84:21) { requestBody: { files: undefined, json: { name: undefined, topic: undefined, type: undefined, nsfw: undefined, bitrate: undefined, user_limit: undefined, parent_id: undefined, position: undefined, permission_overwrites: undefined, rate_limit_per_user: undefined, rtc_region: undefined, video_quality_mode: undefined, default_thread_rate_limit_per_user: undefined, available_tags: undefined, default_reaction_emoji: undefined, default_auto_archive_duration: undefined, default_sort_order: undefined, default_forum_layout: undefined } },
please dont crosspost
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
name: {
_errors: [
{
code: 'BASE_TYPE_REQUIRED',
message: 'This field is required'
}
]
}
}
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/guilds/1126147120852901898/channels'
sorry
im really sorry
i'm assuming you asked ai for that?
copilot
yeah dont because this is what you end up with
hey @arcticwolvinny ❄ 🌈
i solved my problem by giving the code references to it and it gave the code to me accordingly
yeah but dont ask ai because often it'll just lead to more issues
you should code yourself
not ask ai to code for you