diff --git a/.DS_Store b/.DS_Store index 9a1d8ab..388f457 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index 6e321a3..0bd2073 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ +# WARNING: this is a pre-version +The version above is unstable so if you find bugs, please report them in the discord server + +[click here for a stable version](https://www.github.com/DJj123dj/open-ticket/releases/tab/v1.3.2) + + # open-ticket [![discord](https://img.shields.io/badge/discord-join%20our%20server-5865F2.svg?style=flat-square&logo=discord)](https://discord.com/invite/26vT9wt3n3) -[![version](https://img.shields.io/badge/version-1.3.2%20stable-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v1.3.2) +[![version](https://img.shields.io/badge/version-1.4.0%20unstable-red.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v1.4.0) [![npm](https://img.shields.io/badge/npm-external%20libraries%20needed-CB3837.svg?style=flat-square&logo=npm)](#packages) [![license](https://img.shields.io/badge/license-GPL%203.0-important.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE) @@ -8,12 +14,14 @@ This is an open-source discord ticket bot, you can configure it and it comes wit Open Ticket logo -[![announcement](https://img.shields.io/badge/new%20announcement!-open--ticket%20v1.4.0-red.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/discussions/3) - -[![q&a](https://img.shields.io/badge/Q&A-click%20here-blue.svg?style=flat-square)](./documentation/Q&A.md) +[![q&a](https://img.shields.io/badge/Q&A-click%20here-blue.svg?style=flat-square)](./TEMPDOCS.md) ## features - discord interaction buttons +- slash & text commands +- close or delete tickets +- translation possible +- dynamic database system - transcripts - add/remove users from ticket - custom colors & name @@ -45,7 +53,7 @@ if there are any errors, you can open an **issue on github** or **contact me in ### config Our config documentation is moved to another file: -[click here to view](./documentation/CONFIG.md) +[click here to view](./TEMPDOCS.md) ### intents & permissions In the discord developer portal in the "bot" panel you will find 3 switches under the title "Gateaway Intents". The following switches should always be turned on @@ -55,14 +63,10 @@ In the discord developer portal in the "bot" panel you will find 3 switches unde To work the best, the bot needs `ADMINISTRATOR` permissions. You can also configure your own permissions -## v1.4.0 announcement -Hello everyone, soon open-ticket v1.4.0 will be launched, it contains a lot of new features. You can view them below. -[click here to view the announcement](https://github.com/DJj123dj/open-ticket/discussions/3) - ## information -_v1.3.2_ +_v1.4.0 unstable_ -changelog: [click here](./documentation/CHANGELOG.md) +changelog: [click here](./TEMPDOCS.md) © 2022 - DJdj Development | [website](https://www.dj-dj.be) | [discord](https://discord.com/invite/26vT9wt3n3) \ No newline at end of file diff --git a/TEMPDOCS.md b/TEMPDOCS.md new file mode 100644 index 0000000..57eaa2e --- /dev/null +++ b/TEMPDOCS.md @@ -0,0 +1,2 @@ +# documentation +The documentation is not available here, go to the [wiki](https://github.com/DJj123dj/open-ticket/wiki) instead. (the wiki isn't fully done yet!) \ No newline at end of file diff --git a/commands/database.js b/commands/database.js deleted file mode 100644 index 271f232..0000000 --- a/commands/database.js +++ /dev/null @@ -1,21 +0,0 @@ -const discord = require('discord.js') -const bot = require('../index') -const client = bot.client -const config = require("../config.json") - - -module.exports = () => { - client.on("messageCreate",(msg) => { - var args = msg.content.split(" ") - if (args[0] == config.prefix+"resetdatabase" || args[0] == config.prefix+"resetdb"){ - const databaseEmbed = new discord.MessageEmbed() - .setColor(config.main_color) - .setTitle("How to reset the database:") - .setDescription("1: Go to the folder `./storage` in your bot's directory.\n\n2: If posible remove the folders\n`./tickets`, `./transcripts` & `./userTickets`\nfrom the folder `./storage`\n\n3: Restart the bot") - .setFooter({text:"if it doesn't work, create an issue on github or DM me on discord!"}) - - msg.channel.send({embeds:[databaseEmbed]}) - if (config.logs){console.log("[command] "+config.prefix+"resetdatabase (user:"+msg.author.username+")")} - } - }) -} \ No newline at end of file diff --git a/commands/ticketExtra.js b/commands/extracmds.js similarity index 81% rename from commands/ticketExtra.js rename to commands/extracmds.js index cfa84c7..11c59c1 100644 --- a/commands/ticketExtra.js +++ b/commands/extracmds.js @@ -3,28 +3,11 @@ const bot = require('../index') const client = bot.client const config = require("../config.json") - +//============================= +// NOT READY YET +//============================= module.exports = () => { - client.on("messageCreate",msg => { - var args = msg.content.split(" ") - if (args[0] == config.prefix+"ticket" && (args[1] == undefined ||args[1] == "" ||args[1] == null)){ - var TicketHelpMsg = new discord.MessageEmbed() - .setColor(config.main_color) - .setTitle("Ticket commands") - - const prefix = config.prefix - TicketHelpMsg.setDescription("**Go to <#"+config.system.ticket_channel+"> to create a ticket!**\n\n`"+prefix+"ticket msg` ➜ _Admin command._\n`"+prefix+"ticket rename` ➜ _Rename a ticket (no spaces)._\n`"+prefix+"ticket close` ➜ _Close a ticket._\n`"+prefix+"ticket add ` ➜ _Add a user to the ticket._\n`"+prefix+"ticket remove ` ➜ _Remove a user from the ticket._\n`"+prefix+"resetdatabase` ➜ _Steps to reset the database._\n`"+prefix+"resetdb` ➜ _Also database stuff._") - - if (config.credits){ - TicketHelpMsg.setFooter({text:"Open-Ticket by DJdj Development | view on github for source code"}) - } - - msg.channel.send({embeds:[TicketHelpMsg]}) - if (config.logs){console.log("[command] "+config.prefix+"ticket help (user:"+msg.author.username+")")} - } - }) - client.on("messageCreate",msg => { var args = msg.content.split(" ") if (args[0] == config.prefix+"ticket" && args[1] == "close"){ diff --git a/commands/help.js b/commands/help.js new file mode 100644 index 0000000..9608613 --- /dev/null +++ b/commands/help.js @@ -0,0 +1,34 @@ +const discord = require('discord.js') +const bot = require('../index') +const client = bot.client +const config = require("../config.json") + +module.exports = () => { + const helpEmbed = new discord.MessageEmbed() + .setColor(config.main_color) + .setTitle("Help Menu:") + + const prefix = config.prefix + helpEmbed.setDescription("**Go to <#"+config.system.ticket_channel+"> to create a ticket!**\n\n`"+prefix+"msg ` ➜ _Spawn an embed with buttons. (admin only)_\n\n`"+prefix+"rename ` ➜ _Rename a ticket. (no spaces)_\n`"+prefix+"close` ➜ _Close a ticket._\n`"+prefix+"delete` ➜ _Delete a ticket._\n\n`"+prefix+"add ` ➜ _Add a user to the ticket._\n`"+prefix+"remove ` ➜ _Remove a user from the ticket._`") + + if (config.credits) helpEmbed.setFooter({text:"Open-Ticket by DJdj Development | view on github for source code"}) + + + client.on("messageCreate",msg => { + if (!msg.content.startsWith(config.prefix)) return + var args = msg.content.split(config.prefix) + + if (!args[1].startsWith("close") && !args[1].startsWith("delete") && !args[1].startsWith("remove") && !args[1].startsWith("add") && !args[1].startsWith("msg") && !args[1].startsWith("remove") && !args[1].startsWith("msg")){ + + msg.channel.send({embeds:[helpEmbed]}) + if (config.logs){console.log("[command] "+config.prefix+"ticket help (user:"+msg.author.username+")")} + } + }) + + client.on("interactionCreate",(interaction) => { + if (!interaction.isCommand()) return + if (interaction.commandName != "help") return + + interaction.reply({embeds:[helpEmbed]}) + }) +} \ No newline at end of file diff --git a/commands/ticket.js b/commands/ticket.js index 2ae1b5a..fce17e7 100644 --- a/commands/ticket.js +++ b/commands/ticket.js @@ -3,240 +3,60 @@ const bot = require('../index') const client = bot.client const config = require("../config.json") +/** ============================= + ** NOT READY YET + ** =============================*/ module.exports = () => { + /**@type {String[]} */ + var msgIds = [] + config.messages.forEach((msg) => { + msgIds.push(msg.id) + }) + + client.on("messageCreate", msg => { - if (msg.content == config.prefix+"ticket msg"){ - if (msg.member.roles.cache.has(config.botperms_role) == false){ - msg.channel.send({content:config.messages.general.nopermissions}) + if (msg.content.startsWith(config.prefix+"msg")){ + if (config.main_adminroles.some((item)=>{return msg.member.roles.cache.has(item)}) == false){ + msg.channel.send({content:"You have no permission to run this command!"}) return } - var currentTicketButtons = 0 - var ticketButton = new discord.MessageActionRow() - var ticketButton2 = new discord.MessageActionRow() + const id = msg.content.split(config.prefix+"msg")[1].substring(1) ? msg.content.split(config.prefix+"msg")[1].substring(1) : false - const getColor = (color) => { - if (color.toLowerCase() == "red"){ - return "DANGER" - }else if (color.toLowerCase() == "green"){ - return "SUCCESS" - }else if (color.toLowerCase() == "blue" || color.toLowerCase() == "blurple"){ - return "PRIMARY" - }else if (color.toLowerCase() == "black" || color.toLowerCase() == "gray" || color.toLowerCase() == "grey"){ - return "SECONDARY" - }else if (color == "DANGER" || color == "SECONDARY" || color == "SUCCESS" || color == "PRIMARY"){ - return color - }else if (color.toLowerCase() == "none" || color.toLowerCase() == "false" || color.toLowerCase() == ""){ - return "SECONDARY" - }else return "SECONDARY" - } + if (!id) return msg.channel.send({content:"**There is no id!**\nUse: `"+config.prefix+"msg `"}) + if (!msgIds.includes(id)) return msg.channel.send({content:"**Invalid id!**\nChoose from this list:\n_"+msgIds.join("_\n_")+"_"}) - if (config.options.ticket1.enabled){ - if (currentTicketButtons < 4){ - var localTicketButton = ticketButton - }else{ - var localTicketButton = ticketButton2 - } - currentTicketButtons = currentTicketButtons + 1 - - if (config.options.ticket1.isURL == false){ - localTicketButton.addComponents( - new discord.MessageButton() - .setCustomId("newTicket1") - .setDisabled(false) - .setStyle(getColor(config.options.ticket1.color)) - .setEmoji(config.options.ticket1.icon) - ) - }else{ - localTicketButton.addComponents( - new discord.MessageButton() - .setDisabled(false) - .setStyle("LINK") - .setEmoji(config.options.ticket1.icon) - .setURL(config.options.ticket1.url) - ) - } - } - if (config.options.ticket2.enabled){ - if (currentTicketButtons < 4){ - var localTicketButton = ticketButton - }else{ - var localTicketButton = ticketButton2 - } - - currentTicketButtons = currentTicketButtons + 1 - - if (config.options.ticket2.isURL == false){ - localTicketButton.addComponents( - new discord.MessageButton() - .setCustomId("newTicket2") - .setDisabled(false) - .setStyle(getColor(config.options.ticket2.color)) - .setEmoji(config.options.ticket2.icon) - ) - }else{ - localTicketButton.addComponents( - new discord.MessageButton() - .setDisabled(false) - .setStyle("LINK") - .setEmoji(config.options.ticket2.icon) - .setURL(config.options.ticket2.url) - ) - } - } - - if (config.options.ticket3.enabled){ - if (currentTicketButtons < 4){ - var localTicketButton = ticketButton - }else{ - var localTicketButton = ticketButton2 - } - - currentTicketButtons = currentTicketButtons + 1 - - if (config.options.ticket3.isURL == false){ - localTicketButton.addComponents( - new discord.MessageButton() - .setCustomId("newTicket3") - .setDisabled(false) - .setStyle(getColor(config.options.ticket3.color)) - .setEmoji(config.options.ticket3.icon) - ) - }else{ - localTicketButton.addComponents( - new discord.MessageButton() - .setDisabled(false) - .setStyle("LINK") - .setEmoji(config.options.ticket3.icon) - .setURL(config.options.ticket3.url) - ) - } - } - - if (config.options.ticket4.enabled){ - if (currentTicketButtons < 4){ - var localTicketButton = ticketButton - }else{ - var localTicketButton = ticketButton2 - } - - currentTicketButtons = currentTicketButtons + 1 - - if (config.options.ticket4.isURL == false){ - localTicketButton.addComponents( - new discord.MessageButton() - .setCustomId("newTicket4") - .setDisabled(false) - .setStyle(getColor(config.options.ticket4.color)) - .setEmoji(config.options.ticket4.icon) - ) - }else{ - localTicketButton.addComponents( - new discord.MessageButton() - .setDisabled(false) - .setStyle("LINK") - .setEmoji(config.options.ticket4.icon) - .setURL(config.options.ticket4.url) - ) - } - } - - if (config.options.ticket5.enabled){ - if (currentTicketButtons < 4){ - var localTicketButton = ticketButton - }else{ - var localTicketButton = ticketButton2 - } - - currentTicketButtons = currentTicketButtons + 1 - - if (config.options.ticket5.isURL == false){ - localTicketButton.addComponents( - new discord.MessageButton() - .setCustomId("newTicket5") - .setDisabled(false) - .setStyle(getColor(config.options.ticket5.color)) - .setEmoji(config.options.ticket5.icon) - ) - }else{ - localTicketButton.addComponents( - new discord.MessageButton() - .setDisabled(false) - .setStyle("LINK") - .setEmoji(config.options.ticket5.icon) - .setURL(config.options.ticket5.url) - ) - } - } - - if (config.options.ticket6.enabled){ - if (currentTicketButtons < 4){ - var localTicketButton = ticketButton - }else{ - var localTicketButton = ticketButton2 - } - - currentTicketButtons = currentTicketButtons + 1 - - if (config.options.ticket6.isURL == false){ - localTicketButton.addComponents( - new discord.MessageButton() - .setCustomId("newTicket6") - .setDisabled(false) - .setStyle(getColor(config.options.ticket6.color)) - .setEmoji(config.options.ticket6.icon) - ) - }else{ - localTicketButton.addComponents( - new discord.MessageButton() - .setDisabled(false) - .setStyle("LINK") - .setEmoji(config.options.ticket6.icon) - .setURL(config.options.ticket6.url) - ) - } - } - - var categorylist = "" - if (config.options.ticket1.enabled){categorylist = categorylist+"\n"+config.options.ticket1.icon+": **"+config.options.ticket1.name+"**\n"+config.options.ticket1.description} - - if (config.options.ticket2.enabled){categorylist = categorylist+"\n\n"+config.options.ticket2.icon+": **"+config.options.ticket2.name+"**\n"+config.options.ticket2.description} - - if (config.options.ticket3.enabled){categorylist = categorylist+"\n\n"+config.options.ticket3.icon+": **"+config.options.ticket3.name+"**\n"+config.options.ticket3.description} - - if (config.options.ticket4.enabled){categorylist = categorylist+"\n\n"+config.options.ticket4.icon+": **"+config.options.ticket4.name+"**\n"+config.options.ticket4.description} - - if (config.options.ticket5.enabled){categorylist = categorylist+"\n\n"+config.options.ticket5.icon+": **"+config.options.ticket5.name+"**\n"+config.options.ticket5.description} - - if (config.options.ticket6.enabled){categorylist = categorylist+"\n\n"+config.options.ticket6.icon+": **"+config.options.ticket6.name+"**\n"+config.options.ticket6.description} - - - - var ticketEmbed = new discord.MessageEmbed() - if (config.layout.ticketMsg.customColorEnabled){ - ticketEmbed.setColor(config.layout.ticketMsg.customColor) - }else{ticketEmbed.setColor(config.main_color)} - - if (config.layout.ticketMsg.footerEnabled){ - ticketEmbed.setFooter({text:config.layout.ticketMsg.footer}) - } - if (config.layout.ticketMsg.thumbnailEnabled){ - ticketEmbed.setThumbnail(config.layout.ticketMsg.thumbnailURL) - } - - ticketEmbed.setDescription("**Create a ticket:**\nClick one of the buttons below to create a ticket.\n\n__choose a category:__"+categorylist+"\n\n**watch out:**_You can only create "+config.system.max_allowed_tickets+" ticket(s) at a time!_") + const {embed,componentRows} = require("../core/ticketMessageEmbed").createEmbed(id) - - if (currentTicketButtons <= 4){ - var embedComponents = [ticketButton] - }else{var embedComponents = [ticketButton,ticketButton2]} - - msg.channel.send({embeds:[ticketEmbed],components:embedComponents}) + msg.channel.send({embeds:[embed],components:componentRows}) if (config.logs){console.log("[command] "+config.prefix+"ticket msg (user:"+msg.author.username+")")} if (config.logs){console.log("[system] created ticket message")} } }) + + client.on("interactionCreate", (interaction) => { + if (!interaction.isCommand()) return + if (interaction.commandName != "message") return + + if (config.main_adminroles.some((item)=>{return interaction.guild.members.cache.find((m) => m.id == interaction.member.id).roles.cache.has(item)}) == false){ + interaction.reply({content:"You have no permission to run this command!"}) + return + } + + const id = interaction.options.getString("id") + + if (!msgIds.includes(id)) return interaction.reply({content:"**Invalid id!**\nChoose from this list:\n_"+msgIds.join("_\n_")+"_"}) + + const {embed,componentRows} = require("../core/ticketMessageEmbed").createEmbed(id) + + interaction.reply({content:"The embed is in the message below!"}) + interaction.channel.send({embeds:[embed],components:componentRows}) + + if (config.logs){console.log("[command] "+config.prefix+"ticket msg (user:"+interaction.member.user.username+")")} + if (config.logs){console.log("[system] created ticket message")} + + }) } \ No newline at end of file diff --git a/commands/ticketSystem.js b/commands/ticketSystem.js deleted file mode 100644 index 6cf7ee4..0000000 --- a/commands/ticketSystem.js +++ /dev/null @@ -1,309 +0,0 @@ -const discord = require('discord.js') -const bot = require('../index') -const client = bot.client -const config = require("../config.json") - -const ticketStorage = bot.TicketStorage -const userTicketStorage = bot.userTicketStorage -const transcriptStorage = bot.transcriptStorage - -module.exports = () => { - - var closeButton = new discord.MessageActionRow() - .addComponents( - new discord.MessageButton() - .setCustomId("closeTicket") - .setDisabled(false) - .setStyle("SECONDARY") - .setLabel("Close Ticket") - .setEmoji("❌") - ) - - //ticket button click / create ticket - client.on("interactionCreate",interaction => { - - if (interaction.isButton() == false){ - return - } - - if (interaction.customId == "newTicket1"||interaction.customId == "newTicket2"||interaction.customId == "newTicket3"||interaction.customId == "newTicket4"||interaction.customId == "newTicket5"||interaction.customId == "newTicket6"){ - - interaction.deferUpdate() - - if (ticketStorage.getItem(interaction.member.id) == null ||ticketStorage.getItem(interaction.member.id) == "false"|| Number(ticketStorage.getItem(interaction.member.id)) < config.system.max_allowed_tickets){ - - try{ - if (config.system.enable_DM_Messages){ - interaction.member.send(config.messages.dm.newTicket) - } - } - catch{console.log("can't send DM to member || member doesn't allow dm's")} - - - //update storage - ticketStorage.setItem(interaction.member.id,Number(ticketStorage.getItem(interaction.member.id))+1) - var ticketNumber = interaction.member.user.username - - //set ticketName - if (interaction.customId == "newTicket1"){ - var ticketName = config.options.ticket1.channel_prefix+ticketNumber - var logsname = config.options.ticket1.name - }else if (interaction.customId == "newTicket2"){ - var ticketName = config.options.ticket2.channel_prefix+ticketNumber - var logsname = config.options.ticket2.name - }else if (interaction.customId == "newTicket3"){ - var ticketName = config.options.ticket3.channel_prefix+ticketNumber - var logsname = config.options.ticket3.name - }else if (interaction.customId == "newTicket4"){ - var ticketName = config.options.ticket4.channel_prefix+ticketNumber - var logsname = config.options.ticket4.name - }else if (interaction.customId == "newTicket5"){ - var ticketName = config.options.ticket5.channel_prefix+ticketNumber - var logsname = config.options.ticket5.name - }else if (interaction.customId == "newTicket6"){ - var ticketName = config.options.ticket6.channel_prefix+ticketNumber - var logsname = config.options.ticket6.name - } - - //set category - if (config.system.enable_category){ - var Category = config.system.ticket_category - }else{var Category = null} - - var permissionsArray = [] - - //set everyone allowed - if (config.system['has@everyoneaccess']){ - var everyoneAllowPerms = ["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"] - var everyoneDenyPerms = [] - }else{ - var everyoneAllowPerms = [] - var everyoneDenyPerms = ["VIEW_CHANNEL"] - } - permissionsArray.push({ - id:interaction.member.id, - type:"member", - allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"] - }) - permissionsArray.push({ - id:config.botperms_role, - type:"role", - allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"] - }) - permissionsArray.push({ - id:interaction.guild.id, - type:"role", - allow:everyoneAllowPerms, - deny:everyoneDenyPerms - }) - if (config.system.member_role == "" || config.system.member_role == " " || config.system.member_role == "false" || config.system.member_role == "null" || config.system.member_role == "0"){ - permissionsArray.push({ - id:config.system.member_role, - type:"role", - deny:["VIEW_CHANNEL"] - }) - } - - //create the channel - interaction.guild.channels.create(ticketName,{ - type:"GUILD_TEXT", - parent:Category, - permissionOverwrites:permissionsArray - }).then(tChannel => { - userTicketStorage.setItem(tChannel.id,interaction.member.id) - - - var ticketEmbed = new discord.MessageEmbed() - if (config.layout.ticketEmbed.customColorEnabled){ - ticketEmbed.setColor(config.layout.ticketEmbed.customColor) - }else{ticketEmbed.setColor(config.main_color)} - - if (config.layout.ticketEmbed.footerEnabled){ - ticketEmbed.setFooter({text:"config.layout.ticketEmbed.footer"}) - } - if (config.layout.ticketEmbed.thumbnailEnabled){ - ticketEmbed.setThumbnail(config.layout.ticketEmbed.thumbnailURL) - } - ticketEmbed.setTitle("You created a ticket!") - ticketEmbed.setDescription(config.messages.ticket.newTicketEmbed) - - tChannel.send({content:"<@"+interaction.member.id+"> <@&"+config.botperms_role+">",embeds:[ticketEmbed],components:[closeButton]}).then(firstmsg => { - firstmsg.pin() - }) - if (config.logs){console.log("[system] created a new ticket (name:"+logsname+",user:"+interaction.user.username+")")} - }) - - - - }else{ - try { - if (config.system.enable_DM_Messages){ - interaction.member.send(config.messages.dm.alreadyCreated) - } - } - catch{console.log("can't send DM to member || member doesn't allow dm's")} - - - } - } - - - - }) - - //closeBAR - var closeBar = new discord.MessageActionRow() - .addComponents( - new discord.MessageButton() - .setCustomId("closeTicketTrue") - .setDisabled(false) - .setStyle("SECONDARY") - .setEmoji("✅") - ) - .addComponents( - new discord.MessageButton() - .setCustomId("closeTicketFalse") - .setDisabled(false) - .setStyle("SECONDARY") - .setEmoji("❌") - ) - - - - client.on("interactionCreate",interaction => { - if (interaction.isButton() == false){ - return - } - if (interaction.customId == "closeTicket"){ - interaction.deferUpdate() - interaction.message.edit({components:[closeBar]}) - } - }) - - client.on("interactionCreate",interaction => { - if (interaction.isButton() == false){ - return - } - if (interaction.customId == "closeTicketFalse"){ - interaction.deferUpdate() - - interaction.message.edit({components:[closeButton]}) - } - }) - - - - client.on("interactionCreate",interaction => { - if (interaction.isButton() == false){ - return - } - if (interaction.customId == "closeTicketTrue"){ - interaction.deferUpdate() - interaction.channel.messages.fetch().then(messages => { - var transcriptArray = [] - messages.forEach(msg => { - if (msg.author.id != client.user.id){ - transcriptArray.push("["+msg.author.username+"]: "+msg.content) - } - }) - var getuserID = userTicketStorage.getItem(interaction.channel.id) - var getusernameStep1 = client.users.cache.find(u => u.id === getuserID) - if (getusernameStep1 == null || getusernameStep1 == undefined || getusernameStep1 == false || getusernameStep1 == ""){ - var getuserNAME = ":usernotfound:" - }else { - var getuserNAME = getusernameStep1.username - } - - - if (config.system.enable_transcript){ - var transcript = transcriptArray.reverse().join("\n") - transcriptStorage.setItem(interaction.channel.id,transcript) - - //transcript color & thumbnail - if (config.layout.transcripts.customColorEnabled){ - var transcriptColor = config.layout.transcripts.customColor - }else{var transcriptColor = config.main_color} - - if (config.layout.transcripts.thumbnailEnabled){ - var transcriptThumbnail = config.layout.transcripts.thumbnailURL - }else{var transcriptThumbnail = ""} - - var splittedTranscript = [transcript.slice(0,2000)] - if (transcript.length > 4000){ - splittedTranscript.push(transcript.slice(2000,4000)) - splittedTranscript.push(transcript.slice(4000)) - }else if (transcript.length > 2000){ - splittedTranscript.push(transcript.slice(2000)) - } - var transcriptEmbed = new discord.MessageEmbed() - .setColor(transcriptColor) - .setAuthor({name:interaction.channel.name + " - ticket created by "+getuserNAME}) - .setTitle("There is a new transcript!") - .setDescription(splittedTranscript[0]) - .setFooter({text:"ticket closed by "+interaction.member.user.username}) - .setThumbnail(transcriptThumbnail) - - if (transcript.length > 4000){ - var transcriptEmbed2 = new discord.MessageEmbed() - .setColor(transcriptColor) - .setAuthor({name:interaction.channel.name + " - ticket created by "+getuserNAME}) - .setTitle("transcript #2") - .setDescription(splittedTranscript[1]) - .setFooter("ticket closed by "+interaction.member.user.username) - .setThumbnail(transcriptThumbnail) - - var transcriptEmbed3 = new discord.MessageEmbed() - .setColor(transcriptColor) - .setAuthor({name:interaction.channel.name + " - ticket created by "+getuserNAME}) - .setTitle("transcript #3") - .setDescription(splittedTranscript[1]) - .setFooter({text:"ticket closed by "+interaction.member.user.username}) - .setThumbnail(transcriptThumbnail) - - client.channels.cache.find(ch => ch.id == config.system.transcript_channel).send({embeds:[transcriptEmbed,transcriptEmbed2,transcriptEmbed3]}) - - }else if (transcript.length > 2000){ - var transcriptEmbed2 = new discord.MessageEmbed() - .setColor(transcriptColor) - .setAuthor({name:interaction.channel.name + " - ticket created by "+getuserNAME}) - .setTitle("transcript #2") - .setDescription(splittedTranscript[1]) - .setFooter({text:"ticket closed by "+interaction.member.user.username}) - .setThumbnail(transcriptThumbnail) - - client.channels.cache.find(ch => ch.id == config.system.transcript_channel).send({embeds:[transcriptEmbed,transcriptEmbed2]}) - }else{ - client.channels.cache.find(ch => ch.id == config.system.transcript_channel).send({embeds:[transcriptEmbed]}) - } - } - - - - interaction.channel.delete() - if (config.logs){console.log("[system] closed a ticket (name:"+interaction.channel.name+",user:"+interaction.user.username+")")} - - - - ticketStorage.setItem(getuserID,Number(ticketStorage.getItem(getuserID)) - 1) - - try { - if (config.system.enable_DM_Messages){ - interaction.member.send(config.messages.dm.closeTicket) - } - } - catch{console.log("can't send DM to member || member doesn't allow dm's")} - }) - - - - - } - }) - - - - process.on('unhandledRejection',error => { - console.log("ERROR: "+error) - }) - -} \ No newline at end of file diff --git a/config.json b/config.json index cea96cc..baad7e3 100644 --- a/config.json +++ b/config.json @@ -1,132 +1,94 @@ { "bot_name":"Wumpus", "main_color":"#fffff", - "auth_token":"the bot's auth token", - "botperms_role":"the id from an admin role (they can do admin things with the bot)", - "prefix":"!", + "server_id":"935983011281903676", + "auth_token":"OTU4MjkwNjExMzMxNTM4OTc1.YkLLrQ.J9yfO7LgXplNahXv7xQNNvKG6fY", + "main_adminroles":["936153662668034058"], + "prefix":"!ticket ", "logs":true, + "languagefile":"english.json (currently not working)", "credits":true, "status":{ "enabled":true, - "type":"PLAYING | LISTENING | WATCHING | CUSTOM", + "type":"PLAYING", "text":"!ticket" }, "system":{ - "ticket_channel":"id of the channel with the !ticket msg", - "max_allowed_tickets":5, + "ticket_channel":"968899402020306994", + "max_allowed_tickets":3, "enable_DM_Messages":true, - "enable_category":false, - "ticket_category":"the id of a category for the tickets", - "has@everyoneaccess":false, - "member_role":"this role doesn't have access to tickets", + "member_role":"936153574650544180", - "enable_transcript":false, - "transcript_channel":"the channel for transcripts" + "enable_transcript":true, + "enable_DM_transcript":true, + "transcript_channel":"968899606912061490" }, - "messages":{ - "general":{ - "nopermissions":"**You don't have permissions to run this command!**" - }, - "dm":{ - "alreadyCreated":"**You currently have as many open tickets as the maximum allowed!**", - "newTicket":"You created a new ticket in our server, the staff will come and help you soon!", - "closeTicket":"**Your ticket is closed!**" - }, - "ticket":{ - "newTicketEmbed":"You created a ticket!\n\n_Click on the close button below to close this ticket_" - } - }, - - "layout":{ - "transcripts":{ - "customColorEnabled":false, - "customColor":"#ffffff", - "thumbnailEnabled":false, - "thumbnailURL":"https://www.example.com/path/to/image.png" - }, - "ticketMsg":{ - "customColorEnabled":false, - "customColor":"#ffffff", - "footerEnabled":false, - "footer":"We are using open-tickets from DJj123dj", - "thumbnailEnabled":false, - "thumbnailURL":"https://www.example.com/path/to/image.png" - }, - "ticketEmbed":{ - "customColorEnabled":false, - "customColor":"#ffffff", - "footerEnabled":false, - "footer":"This is embed in the start of a ticket.", - "thumbnailEnabled":false, - "thumbnailURL":"https://www.example.com/path/to/image.png" - } - }, - - "options":{ - "ticket1":{ - "enabled":true, - "icon":"🎫", - "description":"Create a general ticket.", - "name":"Ticket", - "channel_prefix":"ticket-", - "color":"red | green | blue | gray | none", - "isURL":false, - "url":"https://www.example.com/a/random/path/to/a/website" - }, - "ticket2":{ - "enabled":false, - "icon":"💼", - "description":"Do you want to apply? Then click here!", - "name":"Apply", - "channel_prefix":"apply-", - "color":"red | green | blue | gray | none", - "isURL":false, - "url":"https://www.example.com/a/random/path/to/a/website" - }, - "ticket3":{ - "enabled":false, - "icon":"❓", - "description":"Click here if you have a question about the server.", + "options":[ + { + "id":"general", "name":"Question", - "channel_prefix":"question-", - "color":"red | green | blue | gray | none", - "isURL":false, - "url":"https://www.example.com/a/random/path/to/a/website" + "description":"Create this ticket if you have a question.", + "icon":"🎫", + "label":"question", + "type":"ticket", + + "color":"gray", + "adminroles":["936153350704091167"], + "channelprefix":"question-", + "category":"935983011281903678", + "message":"You created a ticket!", + "enableDMMessage":true + }, - "ticket4":{ - "enabled":false, - "icon":"🛒", - "description":"Buy something in our shop.", - "name":"Shop", - "channel_prefix":"shop-", - "color":"red | green | blue | gray | none", - "isURL":false, - "url":"https://www.example.com/a/random/path/to/a/website" - }, - "ticket5":{ - "enabled":false, - "icon":"😄", - "description":"hello", - "name":"AnotherTicket", - "channel_prefix":"prefix-", - "color":"red | green | blue | gray | none", - "isURL":false, - "url":"https://www.example.com/a/random/path/to/a/website" - }, - "ticket6":{ - "enabled":false, - "icon":"😄", - "description":"hello", - "name":"AnotherTicket", - "channel_prefix":"prefix-", - "color":"red | green | blue | gray | none", - "isURL":false, - "url":"https://www.example.com/a/random/path/to/a/website" + { + "id":"apply", + "name":"Apply", + "description":"Create this ticket if you want to apply.", + "icon":"💼", + "label":"apply", + "type":"ticket", + + "color":"green", + "adminroles":["936153350704091167"], + "channelprefix":"apply-", + "category":"935983011281903678", + "message":"You created a ticket!", + "enableDMMessage":true + } - } + ], + + "messages":[ + { + "id":"1", + "name":"Choose Your Ticket", + "description":"You can click one of the buttons below!\nYou can also customize all the embeds now!", + "enableFooter":true, + "footer":"Open Ticket v1.4.0 beta - sneakpeak", + "enableThumbnail":false, + "thumbnail":"https://www.example.com/catmemes/cat.png", + "color":"#0075e9", + "options":["general","apply"], + "enableTicketExplaination":true, + "enableMaxTicketsWarning":true + }, + { + "id":"5", + "name":"sodfjiqdosmifj", + "description":"Youoidjfddiddjfmqoisdjf so customize all the embeds now!", + "enableFooter":true, + "footer":"Open Tiiiieakpeak", + "enableThumbnail":false, + "thumbnail":"https://www.example.com/catmemes/cat.png", + "color":"#0075e9", + "options":["apply"], + "enableTicketExplaination":true, + "enableMaxTicketsWarning":true + } + ] } \ No newline at end of file diff --git a/checker.js b/core/checker.js similarity index 98% rename from checker.js rename to core/checker.js index 0bdec6d..4f0f219 100644 --- a/checker.js +++ b/core/checker.js @@ -1,6 +1,10 @@ +/** ============================= + ** NOT READY YET + ** =============================*/ + module.exports = async () => { const chalk = await (await import("chalk")).default - const config = require("./config.json") + const config = require("../config.json") var errorList = [] var isError = false var warnList = [] diff --git a/core/closebuttons.js b/core/closebuttons.js new file mode 100644 index 0000000..0cd6ea9 --- /dev/null +++ b/core/closebuttons.js @@ -0,0 +1,206 @@ +const discord = require('discord.js') +const bot = require('../index') +const client = bot.client +const config = require("../config.json") + + +module.exports = () => { + //closebar + var closeBar = new discord.MessageActionRow() + .addComponents( + new discord.MessageButton() + .setCustomId("closeTicketTrue") + .setDisabled(false) + .setStyle("SECONDARY") + .setEmoji("✅") + ) + .addComponents( + new discord.MessageButton() + .setCustomId("closeTicketFalse") + .setDisabled(false) + .setStyle("SECONDARY") + .setEmoji("❌") + ) + var deleteBar = new discord.MessageActionRow() + .addComponents( + new discord.MessageButton() + .setCustomId("deleteTicketTrue") + .setDisabled(false) + .setStyle("SECONDARY") + .setEmoji("✅") + ) + .addComponents( + new discord.MessageButton() + .setCustomId("deleteTicketFalse") + .setDisabled(false) + .setStyle("SECONDARY") + .setEmoji("❌") + ) + var deleteBar1 = new discord.MessageActionRow() + .addComponents( + new discord.MessageButton() + .setCustomId("deleteTicketTrue1") + .setDisabled(false) + .setStyle("SECONDARY") + .setEmoji("✅") + ) + .addComponents( + new discord.MessageButton() + .setCustomId("deleteTicketFalse1") + .setDisabled(false) + .setStyle("SECONDARY") + .setEmoji("❌") + ) + //closebutton + var closeRowNormal = new discord.MessageActionRow() + .addComponents( + new discord.MessageButton() + .setCustomId("closeTicket") + .setDisabled(false) + .setStyle("SECONDARY") + .setLabel("Close Ticket") + .setEmoji("🔒") + ) + .addComponents( + new discord.MessageButton() + .setCustomId("deleteTicket") + .setDisabled(false) + .setStyle("DANGER") + .setLabel("Delete Ticket") + .setEmoji("❌") + ) + var closeRowClosed = new discord.MessageActionRow() + .addComponents( + new discord.MessageButton() + .setCustomId("deleteTicket1") + .setDisabled(false) + .setStyle("DANGER") + .setLabel("Delete Ticket") + .setEmoji("❌") + ) + .addComponents( + new discord.MessageButton() + .setCustomId("sendTranscript") + .setDisabled(false) + .setStyle("SECONDARY") + .setLabel("Send Transcript File") + .setEmoji("📄") + ) + + + //NORMAL CLOSE + client.on("interactionCreate",interaction => { + if (!interaction.isButton()) return + if (interaction.customId != "closeTicket") return + + interaction.deferUpdate() + interaction.message.edit({components:[closeBar]}) + + }) + client.on("interactionCreate",interaction => { + if (!interaction.isButton()) return + if (interaction.customId != "closeTicketFalse") return + + interaction.deferUpdate() + interaction.message.edit({components:[closeRowNormal]}) + }) + client.on("interactionCreate",interaction => { + if (!interaction.isButton()) return + if (interaction.customId != "closeTicketTrue") return + + interaction.deferUpdate() + interaction.message.edit({components:[closeRowClosed]}) + + /** + * @type {String} + */ + const name = interaction.channel.name + var prefix = "" + const tickets = config.options + tickets.forEach((ticket) => { + if (name.startsWith(ticket.channelprefix)){ + prefix = ticket.channelprefix + } + }) + + require("./ticketCloser").closeTicket(interaction,prefix,"close") + }) + + + //NORMAL DELETE + client.on("interactionCreate",interaction => { + if (!interaction.isButton()) return + if (interaction.customId != "deleteTicket") return + + interaction.deferUpdate() + interaction.message.edit({components:[deleteBar]}) + + }) + client.on("interactionCreate",interaction => { + if (!interaction.isButton()) return + if (interaction.customId != "deleteTicketFalse") return + + interaction.deferUpdate() + interaction.message.edit({components:[closeRowNormal]}) + }) + client.on("interactionCreate",interaction => { + if (!interaction.isButton()) return + if (interaction.customId != "deleteTicketTrue") return + + interaction.deferUpdate() + + /** + * @type {String} + */ + const name = interaction.channel.name + var prefix = "" + const tickets = config.options + tickets.forEach((ticket) => { + if (name.startsWith(ticket.channelprefix)){ + prefix = ticket.channelprefix + } + }) + + require("./ticketCloser").closeTicket(interaction,prefix,"delete") + }) + + + + + //CLOSED DELETE + client.on("interactionCreate",interaction => { + if (!interaction.isButton()) return + if (interaction.customId != "deleteTicket1") return + + interaction.deferUpdate() + interaction.message.edit({components:[deleteBar1]}) + + }) + client.on("interactionCreate",interaction => { + if (!interaction.isButton()) return + if (interaction.customId != "deleteTicketFalse1") return + + interaction.deferUpdate() + interaction.message.edit({components:[closeRowClosed]}) + }) + client.on("interactionCreate",interaction => { + if (!interaction.isButton()) return + if (interaction.customId != "deleteTicketTrue1") return + + interaction.deferUpdate() + + /** + * @type {String} + */ + const name = interaction.channel.name + var prefix = "" + const tickets = config.options + tickets.forEach((ticket) => { + if (name.startsWith(ticket.channelprefix)){ + prefix = ticket.channelprefix + } + }) + + require("./ticketCloser").closeTicket(interaction,prefix,"deletenotranscript") + }) +} \ No newline at end of file diff --git a/storage/storage.js b/core/dynamicdatabase/storage.js similarity index 83% rename from storage/storage.js rename to core/dynamicdatabase/storage.js index 67d979b..1af2cff 100644 --- a/storage/storage.js +++ b/core/dynamicdatabase/storage.js @@ -1,3 +1,7 @@ +/** ============================= + ** NOT READY YET + ** must be dynamic + ** =============================*/ const LocalStorage = require("node-localstorage") const ticketStorage = new LocalStorage.LocalStorage("./storage/tickets") diff --git a/core/getoptions.js b/core/getoptions.js new file mode 100644 index 0000000..60ff236 --- /dev/null +++ b/core/getoptions.js @@ -0,0 +1,113 @@ +const config = require("../config.json") + +/** + * @param {Number} index + * @param {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"adminroles"|"channelprefix"|"category"|"message"|"enableDMMessage"} value + */ +exports.getTicketValue = (index,value) => { + if (value == "id"){ + return "newT"+config.options[index][value] + } + return config.options[index][value] +} + +/** + * @param {Number} index + * @param {"id"|"name"|"description"|"icon"|"label"|"type"|"url"} value + */ + exports.getWebsiteValue = (index,value) => { + return config.options[index][value] +} + +/** + * @param {Number} index + * @param {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"roles"|"mode"|"enableDMMessage"} value + */ +exports.getRoleValue = (index,value) => { + return config.options[index][value] +} + +/** + * @param {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"adminroles"|"channelprefix"|"category"|"message"|"enableDMMessage"} value + */ + exports.getTicketValues = (value) => { + var result = [] + config.options.forEach((o) => { + if (value == "id"){ + result.push("newT"+o[value]) + }else{ + result.push(o[value]) + } + }) + return result +} + +/** + * @param {"id"|"name"|"description"|"icon"|"label"|"type"|"url"} value + */ + exports.getWebsiteValues = (value) => { + var result = [] + config.options.forEach((o) => { + result.push(o[value]) + }) + return result +} + +/** + * @param {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"roles"|"mode"|"enableDMMessage"} value + */ +exports.getRoleValues = (value) => { + var result = [] + config.options.forEach((o) => { + result.push(o[value]) + }) + return result +} + +class TicketOptions { + constructor() { + this.id = "" + this.name = "" + this.description = "" + this.icon = "" + this.label = "" + this.type = "" + this.color = "" + this.adminroles = ["",""] + this.channelprefix = "" + this.category = "" + this.message = "" + this.enableDMMessage = true + } +} +/** + * + * @param {String} id + * @returns {TicketOptions|false} + */ +exports.getOptionsById = (id) => { + var result = false + config.options.forEach((option) => { + if ("newT"+option.id == id){ + result = option + } + }) + return result +} + +exports.exportedOptionClass = class { + constructor() { + this.id = "" + this.name = "" + this.description = "" + this.icon = "" + this.label = "" + this.type = "" + this.color = "" + this.adminroles = ["",""] + this.channelprefix = "" + this.category = "" + this.message = "" + this.enableDMMessage = true + } +} \ No newline at end of file diff --git a/core/slashSystem/slashDisable.js b/core/slashSystem/slashDisable.js new file mode 100644 index 0000000..0eef12a --- /dev/null +++ b/core/slashSystem/slashDisable.js @@ -0,0 +1,23 @@ +const discord = require("discord.js") +const client = require("../../index").client +const config = require("../../config.json") +const getoptions = require("../getoptions") + +module.exports = async () => { + const chalk = (await import("chalk")).default + + console.log(chalk.red("\nINSTRUCTIONS:\n\n1: Run the command you want to delete in discord.\n2: You get the message 'This command is now deleted!'\n3: There is also a message in the console that says the command is deleted.\n4: reload your discord.")) + client.on("interactionCreate",(interaction) => { + if (!interaction.isCommand()) return console.log("this isn't a command!") + + interaction.reply({content:"This command is now deleted!"}) + + try { + client.application.commands.delete(interaction.commandId,interaction.guild.id).then(() => { + console.log("deleted the command",chalk.blue(interaction.commandName),"(id:",interaction.commandId+")") + }) + }catch{ + console.log(chalk.red("something went wrong by the deleting of this command!")) + } + }) +} \ No newline at end of file diff --git a/core/slashSystem/slashEnable.js b/core/slashSystem/slashEnable.js new file mode 100644 index 0000000..fd0e448 --- /dev/null +++ b/core/slashSystem/slashEnable.js @@ -0,0 +1,162 @@ +const discord = require("discord.js") +const client = require("../../index").client +const config = require("../../config.json") +const getoptions = require("../getoptions") + +module.exports = async () => { + const chalk = (await import("chalk")).default + const sid = config.server_id + + const ids = getoptions.getTicketValues("id") + /**@type {[{name:String,value:String}]} */ + var choices = [] + ids.forEach((id) => { + const option = getoptions.getOptionsById(id) + console.log(option.id) + choices.push({name:option.name,value:option.id}) + }) + + /**@type {[{name:String,value:String}]} */ + var msgchoices = [] + config.messages.forEach((msg) => { + msgchoices.push({name:msg.id,value:msg.id}) + }) + + var readystats = 0 + + setInterval(() => { + console.log("[status] there are "+chalk.blue(readystats+" out of 8")+" commands ready! (this can take some time)") + if (readystats >= 8){ + console.log(chalk.green("ready!")) + console.log(chalk.blue("you can now start the bot with 'npm start'!")) + process.exit(1) + } + },1000) + + //create a ticket (/new or /ticket) + client.application.commands.create({ + name:"ticket", + description:"Create a ticket!", + defaultPermission:true, + type:"CHAT_INPUT", + options:[ + { + type:"STRING", + name:"type", + description:"The type of ticket.", + required:true, + choices:choices + + } + ] + },sid).then(() => { + readystats++ + }) + + client.application.commands.create({ + name:"new", + description:"Create a ticket!", + defaultPermission:true, + type:"CHAT_INPUT", + options:[ + { + type:"STRING", + name:"type", + description:"The type of ticket.", + required:true, + choices:choices + + } + ] + },sid).then(() => { + readystats++ + }) + + //help + client.application.commands.create({ + name:"help", + description:"The help menu", + defaultPermission:true, + type:"CHAT_INPUT" + },sid).then(() => { + readystats++ + + }) + + //close + client.application.commands.create({ + name:"close", + description:"Close the current ticket.", + defaultPermission:true, + type:"CHAT_INPUT" + },sid).then(() => { + readystats++ + }) + + //delete + client.application.commands.create({ + name:"delete", + description:"Delete the current ticket.", + defaultPermission:true, + type:"CHAT_INPUT" + },sid).then(() => { + readystats++ + }) + + //msg + client.application.commands.create({ + name:"message", + description:"Create a ticket message.", + defaultPermission:true, + type:"CHAT_INPUT", + options:[ + { + type:"STRING", + name:"id", + description:"The message id.", + required:true, + choices:msgchoices + + } + ] + },sid).then(() => { + readystats++ + }) + + //add + client.application.commands.create({ + name:"add", + description:"Add people to this ticket.", + defaultPermission:true, + type:"CHAT_INPUT", + options:[ + { + type:"USER", + name:"user", + description:"The user to add.", + required:true + } + ] + },sid).then(() => { + readystats++ + }) + + //remove + client.application.commands.create({ + name:"remove", + description:"Remove people from this ticket.", + defaultPermission:true, + type:"CHAT_INPUT", + options:[ + { + type:"USER", + name:"user", + description:"The user to remove.", + required:true + } + ] + },sid).then(() => { + readystats++ + }) + +} \ No newline at end of file diff --git a/core/ticketCloser.js b/core/ticketCloser.js new file mode 100644 index 0000000..ffbd234 --- /dev/null +++ b/core/ticketCloser.js @@ -0,0 +1,153 @@ +const discord = require('discord.js') +const bot = require('../index') +const client = bot.client +const config = require("../config.json") + +const ticketStorage = bot.TicketStorage +const userTicketStorage = bot.userTicketStorage +const transcriptStorage = bot.transcriptStorage + +/** + * + * @param {discord.Interaction} interaction + * @param {String} prefix + * @param {"delete"|"close"|"deletenotranscript"} mode + */ +exports.closeTicket = async (interaction,prefix,mode) => { + const channelmessages = await interaction.channel.messages.fetch() + + channelmessages.sweep((msgSweep) => { + return msgSweep.author.id == client.user.id + }) + + /** + * @type {String} ticketuserarray + */ + const ticketuserarray = interaction.channel.name + const ticketusername = ticketuserarray.split(prefix)[1] + + var getuserID = userTicketStorage.getItem(interaction.channel.id) + var getusernameStep1 = client.users.cache.find(u => u.id === getuserID) + + var enableTranscript = true + + if (mode == "delete"){ + interaction.channel.delete() + if (config.logs){console.log("[system] deleted a ticket (name:"+interaction.channel.name+",user:"+interaction.user.username+")")} + + ticketStorage.setItem(getuserID,Number(ticketStorage.getItem(getuserID)) - 1) + }else if (mode == "close"){ + var permissionArray = [] + permissionArray.push({ + id:getusernameStep1.id, + type:"member", + allow:["VIEW_CHANNEL"], + deny:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES"] + }) + + permissionArray.push({ + id:interaction.guild.id, + type:"role", + deny:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"] + }) + + interaction.channel.permissionOverwrites.set(permissionArray) + + //message + var closeButtonRow = new discord.MessageActionRow() + .addComponents( + new discord.MessageButton() + .setCustomId("deleteTicket1") + .setDisabled(false) + .setStyle("DANGER") + .setLabel("Delete Ticket") + .setEmoji("❌") + ) + .addComponents( + new discord.MessageButton() + .setCustomId("sendTranscript") + .setDisabled(false) + .setStyle("SECONDARY") + .setLabel("Send Transcript File") + .setEmoji("📄") + ) + const embed = new discord.MessageEmbed() + .setColor(config.main_color) + .setTitle("Closed this ticket!") + .setDescription("Only admins can now talk in this ticket!\n\n*Click on the button below to delete this ticket*") + interaction.channel.send({embeds:[embed],components:[closeButtonRow]}) + }else if (mode == "deletenotranscript"){ + enableTranscript = false + interaction.channel.delete() + if (config.logs){console.log("[system] deleted a ticket (name:"+interaction.channel.name+",user:"+interaction.user.username+")")} + + ticketStorage.setItem(getuserID,Number(ticketStorage.getItem(getuserID)) - 1) + } + + if (enableTranscript == true && mode != "deletenotranscript"){ + + if (config.system.enable_transcript || config.system.enable_DM_transcript){ + var fileattachment = await require("./transcript").createTranscript(channelmessages) + + if (fileattachment == false){console.log("[transcript] internal error: no transcript is created!");return} + } + + if (getusernameStep1 == null || getusernameStep1 == undefined || getusernameStep1 == false || getusernameStep1 == ""){ + var getuserNAME = ":usernotfound:" + }else { + var getuserNAME = getusernameStep1.username + } + + if (config.system.enable_transcript){ + const transcriptEmbed = new discord.MessageEmbed() + .setColor(config.main_color) + .setTitle("A new transcript is here!") + .setAuthor({name:interaction.user.username,iconURL:interaction.user.displayAvatarURL({format:"png"})}) + .setDescription("You can find the transcript in the text file above!") + .setFooter({text:"ticket: "+ticketuserarray}) + + interaction.guild.channels.cache.find(c => c.id == config.system.transcript_channel).send({ + embeds:[transcriptEmbed], + files:[fileattachment] + }) + } + + if (config.system.enable_DM_transcript){ + const transcriptEmbed = new discord.MessageEmbed() + .setColor(config.main_color) + .setTitle("Here is a transcript of your ticket!") + .setDescription("You can find the transcript in the text file above!") + .setFooter({text:"ticket: "+ticketuserarray}) + + getusernameStep1.send({ + embeds:[transcriptEmbed], + files:[fileattachment] + }) + } + } +} + +exports.runThis = () => { + client.on("interactionCreate",async (interaction) => { + if (!interaction.isButton()) return + if (interaction.customId != "sendTranscript") return + + interaction.deferUpdate() + + const channelmessages = await interaction.channel.messages.fetch() + + channelmessages.sweep((msgSweep) => { + return msgSweep.author.id == client.user.id + }) + + var fileattachment = await require("./transcript").createTranscript(channelmessages) + + if (fileattachment == false){ + console.log("[transcript] internal error: no transcript is created!") + interaction.channel.send({content:"**Something went wrong while making the transcript!**\nPlease try again another time!"}) + return + } + + interaction.channel.send({content:"**Here is the transcript:**",files:[fileattachment]}) + }) +} \ No newline at end of file diff --git a/core/ticketMessageEmbed.js b/core/ticketMessageEmbed.js new file mode 100644 index 0000000..2d85bee --- /dev/null +++ b/core/ticketMessageEmbed.js @@ -0,0 +1,133 @@ +const discord = require('discord.js') +const bot = require('../index') +const client = bot.client +const config = require("../config.json") +const getOptions = require("./getoptions") +const getbyId = getOptions.getOptionsById + +/** + * + * @param {String} id the id from an open-ticket embed + * @returns {{embed:discord.MessageEmbed,componentRows:discord.MessageActionRow[]}} discord embed + */ + + + +exports.createEmbed = (id) => { + //general importing + const data = require("./utils/getTicketMessages").getTicketMessage(id) + /**@type {getOptions.exportedOptionClass[]}*/ + var buttons = [] + + data.options.forEach((option) => { + var optionIdStats = getbyId("newT"+option) + + if (!optionIdStats){ + var optionIdStats = { + id:"NOTICKET", + name:"ERROR", + description:"There is a ticket in your config.json/messages that doesn't exist.", + icon:"", + label:"ERROR", + type:"ticket", + color:"red", + adminroles:["0"], + channelprefix:"error-", + category:"", + message:"ERROR!", + enableDMMessage:false + + } + return + } + buttons.push(optionIdStats) + }) + + //create the embed + const embed = new discord.MessageEmbed() + .setColor(data.color) + .setTitle(data.name) + if (data.enableFooter) embed.setFooter({text:data.footer}) + if (data.enableThumbnail) embed.setThumbnail(data.thumbnail) + + var description = data.description + if (data.enableTicketExplaination){ + description = description+"\n\n__choose a category:__\n" + + var ticketExplainations = [] + buttons.forEach((button) => { + var explaination = button.icon+" **"+button.name+":**\n"+button.description + ticketExplainations.push(explaination) + }) + + description = description+ticketExplainations.join("\n\n") + } + + if (data.enableMaxTicketsWarning){ + description = description+"\n\n**Warning:** _You can only create "+config.system.max_allowed_tickets+" ticket(s) at a time!_" + } + + embed.setDescription(description) + + //create the components + var AmountOfRows = Math.ceil(buttons.length / 4) + var currentRow = 0 + + /** + * @type {discord.MessageActionRow[]} + */ + var componentRows = [] + + for (let i = AmountOfRows; i > 0; i--){ + + componentRows.push(new discord.MessageActionRow()) + } + + const getColor = (color) => { + if (color.toLowerCase() == "red"){ + return "DANGER" + }else if (color.toLowerCase() == "green"){ + return "SUCCESS" + }else if (color.toLowerCase() == "blue" || color.toLowerCase() == "blurple"){ + return "PRIMARY" + }else if (color.toLowerCase() == "black" || color.toLowerCase() == "gray" || color.toLowerCase() == "grey"){ + return "SECONDARY" + }else if (color == "DANGER" || color == "SECONDARY" || color == "SUCCESS" || color == "PRIMARY"){ + return color + }else if (color.toLowerCase() == "none" || color.toLowerCase() == "false" || color.toLowerCase() == ""){ + return "SECONDARY" + }else return "SECONDARY" + } + + buttons.forEach((button,index) => { + if (button.label){var label = button.label}else{var label = null} + if (button.icon){var icon = button.icon}else{var icon = null} + + var color = getColor(button.color) + + componentRows[currentRow].addComponents([ + new discord.MessageButton() + .setCustomId("newT"+button.id) + .setLabel(label) + .setEmoji(icon) + .setStyle(color) + .setDisabled(false) + ]) + + if (index == 3 || index == 7 || index == 11 || index == 15 || index == 19 || index == 23 || index == 27 || index == 31 || index == 35 || index == 39){ + currentRow = currentRow + 1 + } + }) + + + + //return everything + /** + * @type {{embed:discord.MessageEmbed,componentRows:discord.MessageActionRow[]}} + */ + const returnedData = {embed:embed,componentRows:componentRows} + return returnedData +} + + +this.createEmbed() \ No newline at end of file diff --git a/core/ticketOpener.js b/core/ticketOpener.js new file mode 100644 index 0000000..81b3dfb --- /dev/null +++ b/core/ticketOpener.js @@ -0,0 +1,171 @@ +const discord = require('discord.js') +const bot = require('../index') +const client = bot.client +const config = require("../config.json") + +const getconfigoptions = require("./getoptions") + +const ticketStorage = bot.TicketStorage +const userTicketStorage = bot.userTicketStorage +const transcriptStorage = bot.transcriptStorage + +module.exports = () => { + var closeButton = new discord.MessageActionRow() + .addComponents( + new discord.MessageButton() + .setCustomId("closeTicket") + .setDisabled(false) + .setStyle("SECONDARY") + .setLabel("Close Ticket") + .setEmoji("🔒") + ) + .addComponents( + new discord.MessageButton() + .setCustomId("deleteTicket") + .setDisabled(false) + .setStyle("DANGER") + .setLabel("Delete Ticket") + .setEmoji("❌") + ) + + //ticket button click / create ticket + client.on("interactionCreate",(interaction) => { + if (interaction.isCommand() && (interaction.commandName == "new" || interaction.commandName == "ticket")){ + var customId = "newT"+interaction.options.getString("type") + }else if (interaction.isButton()){ + var customId = interaction.customId + }else return + + if (getconfigoptions.getTicketValues("id").includes(customId)){ + + if (interaction.isButton()){ + interaction.deferUpdate() + }else if (interaction.isCommand()){ + interaction.reply({content:"Your ticket is created!"}) + } + + //ticketoptions from config + const currentTicketOptions = getconfigoptions.getOptionsById(customId) + + if (ticketStorage.getItem(interaction.member.id) == null || ticketStorage.getItem(interaction.member.id) == "false"|| Number(ticketStorage.getItem(interaction.member.id)) < config.system.max_allowed_tickets){ + + try{ + if (config.system.enable_DM_Messages){ + interaction.member.send({content:currentTicketOptions.message}) + } + } + catch{console.log("[system] can't send DM to member, member doesn't allow dm's")} + + + + //update storage + ticketStorage.setItem(interaction.member.id,Number(ticketStorage.getItem(interaction.member.id))+1) + var ticketNumber = interaction.member.user.username + + //set ticketName + var ticketName = currentTicketOptions.channelprefix+ticketNumber + var logsname = currentTicketOptions.name + + //category + if (currentTicketOptions.category.length < 16 || currentTicketOptions.category.length > 20){ + var newTicketCategory = null + }else{ + var newTicketCategory = currentTicketOptions.category + } + + var permissionsArray = [] + + //set everyone allowed + if (config.system['has@everyoneaccess']){ + var everyoneAllowPerms = ["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"] + var everyoneDenyPerms = [] + }else{ + var everyoneAllowPerms = [] + var everyoneDenyPerms = ["VIEW_CHANNEL"] + } + permissionsArray.push({ + id:interaction.guild.id, + type:"role", + allow:everyoneAllowPerms, + deny:everyoneDenyPerms + }) + + //add the user that created the ticket + permissionsArray.push({ + id:interaction.member.id, + type:"member", + allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"] + }) + + //add main adminroles + config.main_adminroles.forEach((role) => { + permissionsArray.push({ + id:role, + type:"role", + allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"] + }) + }) + + //add ticket adminroles + /** + * @type {String[]} + */ + const ticketadmin = currentTicketOptions.adminroles + ticketadmin.forEach((role) => { + if (!config.main_adminroles.includes(role)){ + permissionsArray.push({ + id:role, + type:"role", + allow:["ADD_REACTIONS","ATTACH_FILES","EMBED_LINKS","SEND_MESSAGES","VIEW_CHANNEL"] + }) + } + }) + + //add member role + if (config.system.member_role != "" && config.system.member_role != " " && config.system.member_role != "false" && config.system.member_role != "null" && config.system.member_role != "0"){ + permissionsArray.push({ + id:config.system.member_role, + type:"role", + deny:["VIEW_CHANNEL"] + }) + } + + + //create the channel + interaction.guild.channels.create(ticketName,{ + type:"GUILD_TEXT", + parent:newTicketCategory, + reason:"A new ticket was created", + permissionOverwrites:permissionsArray + + }).then((ticketChannel) => { + userTicketStorage.setItem(ticketChannel.id,interaction.member.id) + + var ticketEmbed = new discord.MessageEmbed() + .setColor(config.main_color) + .setTitle("You created a ticket!") + .setDescription("The staff will help you soon!\n\n*Click on the button below to close the ticket!*") + + ticketChannel.send({ + content:"<@"+interaction.member.id+"> @everyone", + embeds:[ticketEmbed], + components:[closeButton] + + }).then(firstmsg => { + firstmsg.pin() + }) + if (config.logs){console.log("[system] created a new ticket (name:"+logsname+",user:"+interaction.user.username+")")} + }) + }else{ + try { + if (config.system.enable_DM_Messages){ + interaction.member.send("you already have the maximum number of tickets allowed!") + } + } + catch{console.log("[system] can't send DM to member, member doesn't allow dm's")} + + + } + } + }) +} \ No newline at end of file diff --git a/core/transcript.js b/core/transcript.js new file mode 100644 index 0000000..475b33a --- /dev/null +++ b/core/transcript.js @@ -0,0 +1,36 @@ +const discord = require('discord.js') +const bot = require('../index') +const client = bot.client +const config = require("../config.json") + +/** + * + * @param {discord.Message[]} messagecollection + * @returns new `discord.messageAttachment` + */ + +exports.createTranscript = async (messagecollection) => { + try { + const filearray = ["TRANSCRIPT START:"] + + messagecollection.reverse() + + + messagecollection.forEach((msg) => { + const timestamp = new Date(msg.createdTimestamp) + + if (msg.content){var content = msg.content}else{var content = "*empty message*"} + + const msgstats = "files: "+msg.attachments.size+" | embeds: "+msg.embeds.length+" | isbot: "+msg.author.bot + filearray.push("["+timestamp.getDate()+"/"+timestamp.getMonth()+"/"+timestamp.getFullYear()+" | "+timestamp.getHours()+":"+timestamp.getMinutes()+":"+timestamp.getSeconds()+" | "+msg.author.tag+" ] ["+msgstats+"]\n"+content+"\n") + }) + + if (filearray.length < 2) filearray.push("transcript is empty") + const filestring = filearray.join("\n") + const filebuff = Buffer.from(filestring,"utf-8") + return new discord.MessageAttachment(filebuff,"transcript.txt") + }catch(err){ + console.log(err) + return false + } +} \ No newline at end of file diff --git a/core/utils/getTicketMessages.js b/core/utils/getTicketMessages.js new file mode 100644 index 0000000..278afb7 --- /dev/null +++ b/core/utils/getTicketMessages.js @@ -0,0 +1,13 @@ +const config = require("../../config.json") +exports.getTicketMessage = (input) => { + var returned = config.messages.find(a => a.id == input) + if (returned){ + return returned + } + var result = config.messages[0] + if (!result){ + throw new Error("'messages' object in config.json is empty") + return + } + return result +} \ No newline at end of file diff --git a/documentation/CHANGELOG.md b/documentation/CHANGELOG.md deleted file mode 100644 index 28e9a93..0000000 --- a/documentation/CHANGELOG.md +++ /dev/null @@ -1,96 +0,0 @@ -# changelog - -## v1.3.2 -### added: -- an alias for !resetdatabase: !resetdb -- you need the "chalk" library now! -- checker.js -- "enabled" option for status -- better console logs -- enable logs option to config -### fixed -- a bug that crashed the bot on using the command !resetdatabase -- "member_role" in config is optional but not recommended -- fixed crash on startup -- fixed bug where the bot crashes by using transcripts -- changed package.json -### removed -- "canvas" library is not longer required -- removed "server_icon" & "server_name" from config - -## v1.3.1 -### added: -- Q&A in the README.md -- v1.4.0 announcement -### fixed -- a bug that happend when you created too much tickets -- deprecation warnings (setAuthor & setFooter) -- the logo in README.md is smaller now -- markdown files relocated -- fixed a bug that some messages appeared in Dutch -### removed -- nothing - -## v1.3.0 -### added: -- now its possible to create 6 tickets instead of 4 -- you can edit the number of tickets per user now -- you can edit & enable/disable all messages -- all embeds are now editable -- the color of the button can be changed -- updated config.json -- updated README.md -- a new type of button is here: website links -### fixed -- nothing at the moment :) -### removed -- nothing - -## v1.2.2 -### added: -- nothing -### fixed: -- a bug that caused the `warn "message" event deprecated` to be displayed every time you start the bot in the console. -- a visual bug that caused the categories from `!ticket msg` to be displayed in a wrong pattern. -### removed: -- nothing - -## v1.2.1 -### added: -- you can disable credits in config.json -### fixed: -- a bug that crashed the bot on startup -### removed -- nothing - -## v1.2.0 -### added: -- the bot is in english now -- you can choose your own ticket options now -- added !resetdatabase -- updated README.md -### fixed: -- the first bugs -### removed: -- some useless commands - -## v1.1.1 -### added: -- added "status" options in config.json -### fixed: -- fixed a bug where the bot's status could be "playing highmt". -### removed: -- nothing - -## v1.1.0 -### added: -- option to choose your own prefix -- enable/disable transcripts -- enable/disable categories -### fixed: -- the bot crashed sometimes -### removed: -- credits - -## v1.0.0 -- initial release \ No newline at end of file diff --git a/documentation/CONFIG.md b/documentation/CONFIG.md deleted file mode 100644 index 19da514..0000000 --- a/documentation/CONFIG.md +++ /dev/null @@ -1,68 +0,0 @@ -# config file -[![discord](https://img.shields.io/badge/discord-join%20our%20server-5865F2.svg?style=flat-square&logo=discord)](https://discord.com/invite/26vT9wt3n3) -[![version](https://img.shields.io/badge/version-1.3.2%20stable-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v1.3.2) -[![npm](https://img.shields.io/badge/npm-external%20libraries%20needed-CB3837.svg?style=flat-square&logo=npm)](#packages) -[![license](https://img.shields.io/badge/license-GPL%203.0-important.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE) - -In this file you find all the information about commands in the config.json file - - -- bot_name ➜ the name from the bot _**type: string**_ -- main_color ➜ the color used in embeds _**type: hex color (#000000)**_ -- auth_token ➜ your bot's token _**type: string**_ -- botperms_role ➜ this role can do all admin commands from the bot _**type: discord role id**_ -- prefix ➜ the prefix _**type: string**_ -- logs ➜ enable logs _**type: boolean**_ -- credits ➜ disable the credits _**type: boolean**_ - -## status: (the status from the bot) -- enabled ➜ enable status _**type: boolean**_ -- type ➜ set the status type _**type: string (PLAYING | LISTENING | WATCHING | CUSTOM)** -- text ➜ set the status text _**type: string**_ - -## system: (the configuration for the ticket system) -- ticket_channel ➜ channel where you are going to set `!ticket msg` _**type: discord channel id**_ -- max_allowed_tickets ➜ the maximum allowed tickets per person _**type: number**_ -- enable_DM_Messages ➜ enable DM messages _**type: boolean**_ -- enable_category ➜ enable category _**type: boolean**_ -- ticket_category ➜ the category id _**type: discord category id**_ -- has@everyoneaccess ➜ when enabled everyone has acces to the tickets _**type: boolean**_ -- member_role ➜ this role doesn't have access to tickets _**type: discord role id**_ -- enable_transcript ➜ enable the transcript _**type: boolean**_ -- transcript_channel ➜ the transcript channel id _**type: discord channel id**_ - -## messages: (general, dm, ticket) -- nopermissions ➜ the message when someone doesn't have permissions _**type: string**_ -- alreadyCreated ➜ if you have too much tickets open _**type: string**_ -- newTicket ➜ when you create a new ticket _**type: string**_ -- closeTicket ➜ when you close a ticket _**type: string**_ -- newTicketEmbed ➜ the first message in the ticket channel _**type: string** - -## layout: (ticketEmbed, ticketMsg, transcript) -`transcript` doesn't have all the options - -- customColorEnabled ➜ custom embed color enabled _**type: boolean** -- customColor ➜ the custom color _**type: hex color (#000000)** -- footerEnabled ➜ custom footer enabled _**type: boolean** -- footer ➜ the custom footer _**type: string** -- thumbnailEnabled ➜ custom thumbnail enabled _**type: boolean** -- thumbnailURL ➜ the image _**type: string** - -## options: (per ticket) -color is not needed when `isURL` is `true` - -- enabled ➜ enable this ticket _**type: boolean** -- icon ➜ the button emoji _**type: emoji or custom emoji** -- description ➜ ticket description _**type: string** -- name ➜ ticket name _**type: string** -- channel_prefix ➜ ticket prefix _**type: string** -- color ➜ button color _**type: string (red|green|blue|gray|none)** -- isURL ➜ create link to a website instead of a normal ticket _**type: boolean** -- url ➜ the website to go to _**type: string** - -# thanks for using open-ticket -I didn't know that open-tickets was going to be so much used. I will be creating more updates in the future! - -If you have an idea for new updates you can always say it in my discord server! - -open-tickets v1.3.2 \ No newline at end of file diff --git a/documentation/Q&A.md b/documentation/Q&A.md deleted file mode 100644 index 9f221a2..0000000 --- a/documentation/Q&A.md +++ /dev/null @@ -1,26 +0,0 @@ -# Question & Answer -## How to install node.js 16? -You can install the latest version of node.js on their [website](https://nodejs.org/en/download/). You also need `npm`! - -## How to install all the npm packages? -If you installed node.js successful, you can run `npm install` in the command prompt and all the required modules will be installed. - -## Where is the config file documentation? -You can find it [here](...) - -**How to start the bot?** -If you successfully installed all the npm modules (see above), you can run `npm start` - -## Do I need to know discord.js? -Technically not, but it is useful to know if there is an error. - -## Why do I get this error? -**Invalid token:** - -_Your discord token is not correct, try to look in the config.json file if it's the correct token._ - -**Privileged intent provided is not enabled or whitelisted:** - -_You must enable all the **Gateaway Intents** in the developer panel in the "bot" tab_ - -### Report other errors to the discord server! \ No newline at end of file diff --git a/index.js b/index.js index 90515b7..8512b54 100644 --- a/index.js +++ b/index.js @@ -1,37 +1,67 @@ const discord = require('discord.js') const config = require('./config.json') const intents = discord.Intents -const client = new discord.Client({intents:[intents.FLAGS.GUILDS,intents.FLAGS.GUILD_MESSAGES,intents.FLAGS.GUILD_MEMBERS]}) +const client = new discord.Client({intents:[intents.FLAGS.GUILDS,intents.FLAGS.GUILD_MESSAGES,intents.FLAGS.GUILD_MEMBERS],partials:["CHANNEL"]}) exports.client = client -require("./checker")() +client.setMaxListeners(20) client.on('ready',async () => { const chalk = await (await import("chalk")).default - console.log(chalk.green("open-ticket ready!")) - if (config.logs){chalk.white("\n\nlogs:\n============")} - if (config.status.enabled){ - client.user.setActivity(config.status.text,{type:config.status.type}) + if (process.argv[2] != "slash"){ + console.log(chalk.green("open-ticket ready!")) + if (config.logs){console.log(chalk.white("\n\nlogs:\n============"))} + if (config.status.enabled){ + client.user.setActivity(config.status.text,{type:config.status.type}) + } + }else{ + console.log(chalk.red("STARTING IN ")+chalk.blue("SLASH MODE")+chalk.red("...")) + console.log("logs:\n================") + console.log("client logged in...") + console.log("loading files...") + if (process.argv[3] == "enable"){ + console.log(chalk.green("switching to slashEnable.js")) + require("./core/slashSystem/slashEnable")() + }else if (process.argv[3] == "disable"){ + console.log(chalk.green("switching to slashDisable.js")) + require("./core/slashSystem/slashDisable")() + }else{ + console.log(chalk.red("Internal Error: unknown slash mode!")) + process.exit(1) + } } }) -var storage = require('./storage/storage') -exports.TicketStorage = storage.ticketStorage -exports.userTicketStorage = storage.userTicketStorage -exports.transcriptStorage = storage.transcriptStorage -exports.ticketNumberStorage = storage.ticketNumberStorage +//checker.js must stand HERE +//before the "if slash" -var ticket = require('./commands/ticket') -ticket() +if (process.argv[2] != "slash"){ + var storage = require('./core/dynamicdatabase/storage') + exports.TicketStorage = storage.ticketStorage + exports.userTicketStorage = storage.userTicketStorage + exports.transcriptStorage = storage.transcriptStorage + exports.ticketNumberStorage = storage.ticketNumberStorage -var ticketSystem = require('./commands/ticketSystem') -ticketSystem() + //commands + require('./commands/ticket')() + require("./commands/help")() -var ticketExtra = require("./commands/ticketExtra") -ticketExtra() + //core + require('./core/ticketOpener')() + require("./core/ticketCloser").runThis() + require("./core/closebuttons")() -var database = require('./commands/database') -database() + /** + * We need: + * - checker.js + * - extracmds.js + */ +} + +process.on('unhandledRejection',async (error) => { + const chalk = await (await import("chalk")).default + console.log(chalk.red("ERROR: ")+error) +}) client.login(config.auth_token) \ No newline at end of file diff --git a/logo.png b/logo.png index e3c7fa6..e6988c9 100644 Binary files a/logo.png and b/logo.png differ diff --git a/originalConfig.json b/originalConfig.json new file mode 100644 index 0000000..fdfeb43 --- /dev/null +++ b/originalConfig.json @@ -0,0 +1,59 @@ +{ + "bot_name":"Wumpus", + "main_color":"#fffff", + "server_id":"the server id (for slash commands)", + "auth_token":"the bot's auth token", + "main_adminroles":["the id's from admin roles"], + "prefix":"!", + "logs":true, + "languagefile":"english.json (currently not working)", + + "credits":true, + "status":{ + "enabled":true, + "type":"PLAYING | LISTENING | WATCHING | CUSTOM", + "text":"!ticket" + }, + + "system":{ + "ticket_channel":"id of the channel with the !ticket msg", + "max_allowed_tickets":5, + "enable_DM_Messages":true, + + "has@everyoneaccess":false, + "member_role":"this role doesn't have access to tickets", + + "enable_transcript":false, + "enable_DM_transcript":false, + "transcript_channel":"the channel for transcripts" + }, + + "options":[ + { + "id":"ticket1", + "name":"Test Ticket", + "description":"Create a general ticket.", + "icon":"🎫", + "label":"i'm a ticket button", + "type":"ticket", + + "color":"red|green|blue|gray|none", + "adminroles":["role id array"], + "channelprefix":"support-", + "category":"discord category id", + "message":"this is send in DM", + "enableDMMessage":true + + } + ], + + "messages":[ + { + "id":"1", + "name":"Choose Your Ticket", + "description":"You can click one of the buttons below!", + "color":"#ffffff", + "options":["ticket1","ticket2"] + } + ] +} \ No newline at end of file diff --git a/package.json b/package.json index feaf758..8cc3974 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "main": "index.js", "scripts": { "start": "node index.js", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "slashEnable":"node index.js slash enable", + "slashDisable":"node index.js slash disable" }, "author": "DJdj Development", "license": "ISC", diff --git a/storage/tickets/779742674932072469 b/storage/tickets/779742674932072469 new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/storage/tickets/779742674932072469 @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/storage/tickets/858640346892337163 b/storage/tickets/858640346892337163 new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/storage/tickets/858640346892337163 @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/storage/userTickets/968902556971585536 b/storage/userTickets/968902556971585536 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968902556971585536 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968902650873675838 b/storage/userTickets/968902650873675838 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968902650873675838 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968903429693001779 b/storage/userTickets/968903429693001779 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968903429693001779 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968903924390174790 b/storage/userTickets/968903924390174790 new file mode 100644 index 0000000..ca9aa59 --- /dev/null +++ b/storage/userTickets/968903924390174790 @@ -0,0 +1 @@ +858640346892337163 \ No newline at end of file diff --git a/storage/userTickets/968913030110904340 b/storage/userTickets/968913030110904340 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968913030110904340 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968915615333093387 b/storage/userTickets/968915615333093387 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968915615333093387 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968917301288108072 b/storage/userTickets/968917301288108072 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968917301288108072 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968920379974373436 b/storage/userTickets/968920379974373436 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968920379974373436 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968920740558684210 b/storage/userTickets/968920740558684210 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968920740558684210 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968921182877388930 b/storage/userTickets/968921182877388930 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968921182877388930 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968921695505223721 b/storage/userTickets/968921695505223721 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968921695505223721 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968922637596258304 b/storage/userTickets/968922637596258304 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968922637596258304 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968922760787161098 b/storage/userTickets/968922760787161098 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968922760787161098 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/968923098571239474 b/storage/userTickets/968923098571239474 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/968923098571239474 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/969289034599919666 b/storage/userTickets/969289034599919666 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/969289034599919666 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/969289151692288100 b/storage/userTickets/969289151692288100 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/969289151692288100 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/969289430370230272 b/storage/userTickets/969289430370230272 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/969289430370230272 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/969289687808241746 b/storage/userTickets/969289687808241746 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/969289687808241746 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/969289892662235188 b/storage/userTickets/969289892662235188 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/969289892662235188 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/969290103337938966 b/storage/userTickets/969290103337938966 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/969290103337938966 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/969290783716941914 b/storage/userTickets/969290783716941914 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/969290783716941914 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/970222239867871272 b/storage/userTickets/970222239867871272 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/970222239867871272 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/970581087891886080 b/storage/userTickets/970581087891886080 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/970581087891886080 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file diff --git a/storage/userTickets/970581271459799040 b/storage/userTickets/970581271459799040 new file mode 100644 index 0000000..71d7104 --- /dev/null +++ b/storage/userTickets/970581271459799040 @@ -0,0 +1 @@ +779742674932072469 \ No newline at end of file