wTornado
wTornado
DIAdiscord.js - Imagine an app
Created by wTornado on 1/18/2024 in #djs-questions
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 }); }, };
16 replies