const Discord = require("discord.js"); const main = require("../index.js"); module.exports = async (bot, interaction) => { if(!interaction.isButton()) return; if(!interaction.channelId === bot.config.channels.tickets) return console.log("How does this button exist..."); if(interaction.user.bot) return console.log("Bot responding to a button..."); let actnId = interaction.customId; // Services if(actnId === "services") { let design = new Discord.MessageActionRow() .addComponents( new Discord.MessageButton({style: "SUCCESS", customId: "logoDesign", label: "Logo Design"}), new Discord.MessageButton({style: "SUCCESS", customId: "motionDesign", label: "Motion Design"}), new Discord.MessageButton({style: "SUCCESS", customId: "3d", label: "3D Modelling"}), new Discord.MessageButton({style: "SUCCESS", customId: "2d", label: "2D Textures"}), new Discord.MessageButton({style: "SUCCESS", customId: "pixelArt", label: "Pixel Art"}) ); const servicesEmbed = new Discord.MessageEmbed() .setTitle("Select Service") .setDescription(`<@${interaction.user.id}>, please select a service for which you would like information.`) .setColor("WHITE") await interaction.reply({ ephemeral: true, embeds: [servicesEmbed], components: [design] }); } if(actnId === "logoDesign" || actnId === "motionDesign" || actnId === "3d" || actnId === "2d" || actnId === "pixelArt") { let category = await main.getTicketCategory(interaction.guild, "Design Tickets") await main.createTicket(category, interaction, actnId); } // Report if(actnId === "report") { let reports = new Discord.MessageActionRow() .addComponents( new Discord.MessageButton({style: "SUCCESS", customId: "userReport", label: "User Report"}), new Discord.MessageButton({style: "SUCCESS", customId: "bugReport", label: "Bug Report"}), new Discord.MessageButton({style: "SUCCESS", customId: "otherReport", label: "Other Report"}) ); const reportsEmbed = new Discord.MessageEmbed() .setTitle("Select Report") .setDescription(`<@${interaction.user.id}>, please select the type of reporting you want to do.`) .setColor("WHITE") await interaction.reply({ ephemeral: true, embeds: [reportsEmbed], components: [reports] }); } if(actnId === "userReport" || actnId === "bugReport" || actnId === "otherReport") { let category = await main.getTicketCategory(interaction.guild, "Reports") await main.createTicket(category, interaction, actnId); } // Partner if(actnId === "partner") { let partners = new Discord.MessageActionRow() .addComponents( new Discord.MessageButton({style: "SUCCESS", customId: "mcPartner", label: "Minecraft Server Partnership"}), new Discord.MessageButton({style: "SUCCESS", customId: "ytPartner", label: "YouTube Partnership"}), new Discord.MessageButton({style: "SUCCESS", customId: "otherPartner", label: "Other Partnership"}) ); const partnersEmbed = new Discord.MessageEmbed() .setTitle("Select Partnership") .setDescription(`<@${interaction.user.id}>, please select the type of partnership that best suits your project.`) .setColor("WHITE") await interaction.reply({ ephemeral: true, embeds: [partnersEmbed], components: [partners] }); } if(actnId === "mcPartner" || actnId === "ytPartner" || actnId === "otherPartner") { let category = await main.getTicketCategory(interaction.guild, "Partnerships") await main.createTicket(category, interaction, actnId); } // Within tickets if(actnId === "cancel") { interaction.message.delete(); } if(actnId === "confirm") { interaction.channel.delete(); } if(actnId === "reject") { interaction.channel.delete(); } if(actnId === "accept") { let embed = interaction.message.embeds[0]; let channel = interaction.channel; interaction.message.delete(); interaction.deferUpdate(); channel.permissionOverwrites.edit(interaction.user, { SEND_MESSAGES: true }); embed.setDescription(`Hello ${interaction.user}, thank you for making a ticket. Please explain below how we can assist you. A member of our team will be with you shortly.`); channel.send({ embeds: [embed] }); if(bot.questionable.includes(embed.title)) { let questions = bot.questions[embed.title]; let question1; let question2; let question3; let question4; let question5; interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("First Question") .setDescription(questions[0]) .setColor("BLUE") ] }).then(msg => { let collectOne = new Discord.MessageCollector(channel, m => (m.author.id === member.id), { time: 7200000 }); collectOne.on("collect", m => { m.delete(); if(!m.content) { interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("No Message Found") .setDescription("No message content.") .setColor("RED") ] }).then(del => { m.delete(); del.delete({ timeout: 10000 }); }); } else if (m.content.length > 1024) { interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("Message Too Long") .setDescription("The message is too long, please shorten your message or create a Pastebin.", "Your message will be cleared in **30 seconds**.") .setColor("RED") ] }).then(del => { m.delete({ timeout: 30000 }); del.delete({ timeout: 30000 }); }); } else { question1 = m.content; collectOne.stop(); } }); collectOne.on("end", collected => { msg.edit({ embeds: [ new Discord.MessageEmbed() .setTitle("Second Question") .setDescription(questions[1]) .setColor("BLUE") ] }) let collectTwo = new Discord.MessageCollector(channel, m => (m.author.id === member.id), { time: 7200000 }); collectTwo.on("collect", m => { m.delete(); if(!m.content) { interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("No Message Found") .setDescription("No message content.") .setColor("RED") ] }).then(del => { m.delete(); del.delete({ timeout: 10000 }); }); } else if (m.content.length > 1024) { interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("Message Too Long") .setDescription("The message is too long, please shorten your message or create a Pastebin.", "Your message will be cleared in **30 seconds**.") .setColor("RED") ] }).then(del => { m.delete({ timeout: 30000 }); del.delete({ timeout: 30000 }); }); } else { question2 = m.content; collectTwo.stop(); } }); collectTwo.on("end", () => { msg.edit({ embeds: [ new Discord.MessageEmbed() .setTitle("Third Question") .setDescription(questions[2]) .setColor("BLUE") ] }) let collectThree = new Discord.MessageCollector(channel, m => (m.author.id === member.id), { time: 7200000 }); collectThree.on("collect", m => { m.delete(); if(!m.content) { interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("No Message Found") .setDescription("No message content.") .setColor("RED") ] }).then(del => { m.delete(); del.delete({ timeout: 10000 }); }); } else if (m.content.length > 1024) { interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("Message Too Long") .setDescription("The message is too long, please shorten your message or create a Pastebin.", "Your message will be cleared in **30 seconds**.") .setColor("RED") ] }).then(del => { m.delete({ timeout: 30000 }); del.delete({ timeout: 30000 }); }); } else { question3 = m.content; collectThree.stop(); } }); collectThree.on("end", () => { msg.edit({ embeds: [ new Discord.MessageEmbed() .setTitle("Fourth Question") .setDescription(questions[3]) .setColor("BLUE") ] }) let collectFour = new Discord.MessageCollector(channel, m => (m.author.id === member.id), { time: 7200000 }); collectFour.on("collect", m => { m.delete(); if(!m.content) { interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("No Message Found") .setDescription("No message content.") .setColor("RED") ] }).then(del => { m.delete(); del.delete({ timeout: 10000 }); }); } else if (m.content.length > 1024) { interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("Message Too Long") .setDescription("The message is too long, please shorten your message or create a Pastebin.", "Your message will be cleared in **30 seconds**.") .setColor("RED") ] }).then(del => { m.delete({ timeout: 30000 }); del.delete({ timeout: 30000 }); }); } else { question4 = m.content; collectFour.stop(); } }); collectFour.on("end", () => { msg.edit({ embeds: [ new Discord.MessageEmbed() .setTitle("Fifth Question") .setDescription(questions[4]) .setColor("BLUE") ] }) let collectFive = new Discord.MessageCollector(channel, m => (m.author.id === member.id), { time: 7200000 }); collectFive.on("collect", m => { m.delete(); if(!m.content) { interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("No Message Found") .setDescription("No message content.") .setColor("RED") ] }).then(del => { m.delete(); del.delete({ timeout: 10000 }); }); } else if (m.content.length > 1024) { interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle("Message Too Long") .setDescription("The message is too long, please shorten your message or create a Pastebin.", "Your message will be cleared in **30 seconds**.") .setColor("RED") ] }).then(del => { m.delete({ timeout: 30000 }); del.delete({ timeout: 30000 }); }); } else { question5 = m.content; collectFive.stop(); } }); collectFive.on("end", () => { msg.delete(); interaction.channel.send({ embeds: [ new Discord.MessageEmbed() .setTitle(`${embed.title} Commission`) .setDescription("Here is all the information about the commission that has just been sent.") .addFields( { name: "Ticket Number", value: `${interaction.channel.name.replace("ticket-", "")}`, inline: true }, { name: "\u200B", value: "\u200B", inline: true }, { name: "Client Username", value: `<@${interaction.channel.topic}> (${interaction.channel.topic})`, inline: true }, { name: questions[0], value: `\`\`\`${question1}\`\`\`` }, { name: questions[1], value: `\`\`\`${question2}\`\`\`` }, { name: questions[2], value: `\`\`\`${question3}\`\`\`` }, { name: questions[3], value: `\`\`\`${question4}\`\`\`` }, { name: questions[4], value: `\`\`\`${question5}\`\`\`` } ) .setColor("BLUE") .setTimestamp() ] }).then(embed => { embed.pin() }); bot.channels.cache.get("922946544016162877").send({ embeds: [ new Discord.MessageEmbed() .setTitle(`${embed.title} Commission`) .setDescription("Here is all the information about the commission that has just been sent.") .addFields( { name: "Ticket Number", value: `${interaction.channel.name.replace("ticket-", "")}`, inline: true }, { name: "\u200B", value: "\u200B", inline: true }, { name: "Client Username", value: `<@${interaction.channel.topic}> (${interaction.channel.topic})`, inline: true }, { name: questions[0], value: `\`\`\`${question1}\`\`\`` }, { name: questions[1], value: `\`\`\`${question2}\`\`\`` }, { name: questions[2], value: `\`\`\`${question3}\`\`\`` }, { name: questions[3], value: `\`\`\`${question4}\`\`\`` }, { name: questions[4], value: `\`\`\`${question5}\`\`\`` } ) .setColor("BLUE") .setTimestamp() ] }) }) }) }) }) }) }) } } }