const { PermissionsBitField, EmbedBuilder, ChannelType, ActionRowBuilder, selectMenuBuilder, SlashCommandBuilder } = require("discord.js"); module.exports = { data: new SlashCommandBuilder() .setName('ticket-set') .setDescription(`this sets up the ticket message and system`) .addChannelOption(option => option.setName('channel').setDescription(`the channel you want to send the ticket message in`).addChannelTypes(ChannelType.GuildText).setRequired(true)) .addChannelOption(option => option.setName('category').setDescription(`the category you want the ticket to be sent in`).addChannelTypes(ChannelType.GuildCategory).setRequired(true)), async execute (interaction) { if (!interaction.member.permissions.has(Discord.PermissionFlagsBits.Administrator)) return interaction.reply({ content: "You must have admin to set up tickets", ephemeral: true }); const channel = interaction.options.getChannel('channel') const category = interaction.options.getChannel('category') ticketSchema.findOne({ Guild: interaction.guild.id}, async (err, data) => { if (!data) { ticketSchema.create({ Guild: interaction.guild.id, Channel: category.id, Ticket: 'first' }) } else { await interaction.reply({ content: "You already have a ticket message set up, use the /ticket-disable command to restart"}) return; } const embed = new EmbedBuilder() .setColor("blue") .setTitle('Ticket System') .setDescription('If you have a problem, open a ticket to talk to staff members!') .setFooter({ text: `${interaction.guild.name} tickets`}) const menu = new ActionRowBuilder() .addComponents( new selectMenuBuilder() .setCustomId('select') .setMaxValues(1) .setPlaceholder('select a topic...') .addOptions( { label: 'General Support', value: 'subject: General support', name: 'general support' }, { label: 'Moderation Support', value: 'subject: Moderation support', name: 'moderation support', }, { label: 'Code Support', value: 'subject: Code support', name: 'code support', }, { label: 'other', value: 'subject: other', name: 'other', }, ) ) console.log(menu) await channel.send({ embeds: [embed], components: [menu] }); await interaction.reply({ content: `your ticket system has been set up in ${channel}`, ephemeral: true }); }); } };