UNPKG

discord-ticket-easy

Version:

- A module allowing the simple creation of a discord ticket with your client supported by Discord.js^14.0.0 - The easiest to use ticket module.

85 lines (62 loc) 3.11 kB
const Discord = require("discord.js"); const { SetupConstructorOptions } = require("../Utils/Constants"); const version = require("../../package.json"); const Client = require("../Classes/Client"); module.exports = class Setup { /** * * @param {Discord.Client} client * @param {SetupConstructorOptions} options */ constructor(client, options) { this.localClient = Client this.client = client this.rolesID = Client.data.moduleData.roleId this.channelID = Client.data.moduleData.channelMessageID this.categorieID = Client.data.moduleData.categorieID this.categorieArchiveID = Client.data.moduleData.categorieArchiveID this.guildID = Client.data.moduleData.guildID this.interaction = options?.interaction } async setupMessageTicket() { if (await this.localClient.isValidApiKey() === false) { throw new Error("Your api key is not valid! Check your vogzcorp profile.") } if (!this.channelID || this.channelID.length > 18 || this.channelID.length < 18) throw new Error("Please enter a correct ID") if (!this.categorieID || this.categorieID.length > 18 || this.categorieID.length < 18) throw new Error("Please enter a correct ID") if (!this.categorieArchiveID || this.categorieArchiveID.length > 18 || this.categorieArchiveID.length < 18) throw new Error("Please enter a correct ID") if (!this.guildID || this.guildID.length > 18 || this.guildID.length < 18) throw new Error("Please enter a correct ID") if (!this.rolesID) throw new Error("Please enter a correct ID") let guild = this.client.guilds.cache.get(this.guildID) if (this.rolesID.length > 1) return this.interaction.reply({content: "You can only add one additional role. To add more than one, please upgrade to the premium version!", ephemeral: true}) let channel = guild.channels.cache.get(this.channelID); let Embed = new Discord.EmbedBuilder() .setTitle("✉️ - Tickets") .setDescription(`Press the button below to open a new ticket.`) .setFooter({text: "EmbedTicket - discord-ticket-easy"}) let button = new Discord.ActionRowBuilder() .addComponents( new Discord.ButtonBuilder() .setCustomId("newTicket") .setLabel('new ticket') .setEmoji("✉️") .setStyle(Discord.ButtonStyle.Primary) ) let aboutPremium = new Discord.ActionRowBuilder() .addComponents( new Discord.ButtonBuilder() .setCustomId("aboutPremium") .setLabel('About Premium') .setEmoji("💎") .setStyle(Discord.ButtonStyle.Primary) ) .addComponents( new Discord.ButtonBuilder() .setLabel(`npm version: ${version.version}`) .setURL("https://github.com/Valogzi/discord-ticket-easy") .setStyle(Discord.ButtonStyle.Link) ) channel.send({embeds: [Embed], components: [button]}) return this.interaction.reply({content: "The ticket is correctly created!", components: [aboutPremium], ephemeral: true}) } }