Danulsan

Untitled

Jun 27th, 2023
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. const { PermissionsBitField, EmbedBuilder, ChannelType, ActionRowBuilder, StringSelectMenuBuilder, SlashCommandBuilder } = require("discord.js");
  2. const ticketSchema = require("../../Schemas.js/ticketSchema");
  3.  
  4. module.exports = {
  5. data: new SlashCommandBuilder()
  6. .setName("ticket-setup")
  7. .setDescription("Sets up a ticket system")
  8. .addChannelOption(option => option.setName("channel").setDescription("The channel you want to set the ticket system up in").addChannelTypes(ChannelType.GuildText).setRequired(true))
  9. .addChannelOption(option => option.setName("category").setDescription("The category you want to send the tickets in").addChannelTypes(ChannelType.GuildCategory).setRequired(true)),
  10. async execute(interaction) {
  11.  
  12. if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({ content: "You must be an admin to set up tickets!", ephermeral: true })
  13.  
  14. const channel = interaction.options.getChannel("channel")
  15. const category = interaction.options.getChannel("category")
  16.  
  17. ticketSchema.findOne({ Guild: interaction.guild.id }, async (err, data) => {
  18.  
  19. if (!data) {
  20. ticketSchema.create({
  21. Guild: interaction.guild.id,
  22. Channel: category.id,
  23. Ticket: "first"
  24. })
  25. } else {
  26. await interaction.reply({ content: "You already have a ticket system set up. You can run /ticket-disable to remove it and restart." })
  27. return;
  28. }
  29. })
  30.  
  31. const embed = new EmbedBuilder()
  32. .setColor("Random")
  33. .setTitle("Ticket System")
  34. .setDescription("Open a ticket to talk with staff about an issue.")
  35. .setFooter({ text: `${interaction.guild.name} tickets!` })
  36.  
  37. const menu = new ActionRowBuilder()
  38. .addComponents(
  39. new StringSelectMenuBuilder()
  40. .setCustomId("select")
  41. .setMaxValues(1)
  42. .setPlaceholder("🥶 Select A Topic")
  43. .addOptions(
  44. {
  45. label: "🌐 General Support",
  46. value: "Subject: General Support"
  47. },
  48. {
  49. label: "🛠️ Moderation Support",
  50. value: "Subject: Moderation Support"
  51. },
  52. {
  53. label: "🥶 Server Support",
  54. value: "Subject: Server Support"
  55. },
  56. {
  57. label: "💸 Other",
  58. value: "Subject: Other"
  59. },
  60. )
  61. )
  62.  
  63. await channel.send({ embeds: [embed], components: [menu] });
  64. await interaction.reply({ content: `Your ticket system has been set up in ${channel}` })
  65. }
  66. }
Add Comment
Please, Sign In to add comment