From 62a1f0f8c155e26f6246959dd951358e83d93581 Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Wed, 8 Jun 2022 17:13:53 +0200 Subject: [PATCH] v2.1.0 push 1 changed some things --- .gitignore | 9 ++++++++- README.md | 6 +++--- TEMPDOCS.md | 5 ----- config.json | 6 +++--- core/checker.js | 21 +++++++++++++++++---- core/dynamicdatabase/cleardata.js | 4 ++-- core/dynamicdatabase/storage.js | 20 ++++++++++---------- core/slashSystem/slashEnable.js | 4 +++- core/ticketOpener.js | 11 +++++++---- index.js | 25 ++++++++++++++----------- package.json | 2 +- 11 files changed, 68 insertions(+), 45 deletions(-) delete mode 100644 TEMPDOCS.md diff --git a/.gitignore b/.gitignore index 77b939d..105d92c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ node_modules/ package-lock.json devConfig.json -.DS_Store \ No newline at end of file +devConfig1.json +devConfig2.json +devConfig3.json +devConfig4.json +devConfig5.json +.DS_Store +openticketdebug.txt +developerChangelog.md \ No newline at end of file diff --git a/README.md b/README.md index 38e4992..c16d928 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # 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-2.0.0%20stable-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v2.0.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) +[![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-2.1.0%20stable-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v2.1.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) This is an open-source discord ticket bot, you can configure it and it comes with cool features like transcripts & custom options! @@ -44,7 +44,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](https://www.github.com/DJj123dj/open-ticket/wiki/config-v2.0.0) +[click here to view](https://www.github.com/DJj123dj/open-ticket/wiki/config-v2.1.0) ### 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 @@ -56,7 +56,7 @@ You can also configure your own permissions ## information -_v2.0.0 unstable_ +_v2.1.0 unstable_ changelog: [click here](https://www.github.com/DJj123dj/open-ticket/wiki/Changelog) diff --git a/TEMPDOCS.md b/TEMPDOCS.md deleted file mode 100644 index 4188c3e..0000000 --- a/TEMPDOCS.md +++ /dev/null @@ -1,5 +0,0 @@ -# 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!) - -## 2.0.0 beta -There is currently no documentation available for open-ticket v2.0.0 beta. So if you want to test it, you need to figure it out on yourself at the moment! \ No newline at end of file diff --git a/config.json b/config.json index ffc16d0..af8b1e8 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "bot_name":"Wumpus", - "main_color":"#fffff", + "main_color":"#ffffff", "server_id":"server id (for slash cmds)", "auth_token":"auth token", "main_adminroles":["discord role id"], @@ -78,10 +78,10 @@ "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 v2.0.0 beta - sneakpeak", + "footer":"Open Ticket v2.1.0 - I'm a footer!", "enableThumbnail":false, "thumbnail":"https://www.example.com/catmemes/cat.png", - "color":"#0075e9", + "color":"#ffffff", "options":["general","apply"], "enableTicketExplaination":true, "enableMaxTicketsWarning":true diff --git a/core/checker.js b/core/checker.js index fc17c58..493c9b0 100644 --- a/core/checker.js +++ b/core/checker.js @@ -47,9 +47,18 @@ exports.checker = async () => { } /**@param {String} value @param {String} path */ - const checkColor = (value,path) => { - if (!/^#[a-f0-9]{6}$/.test(value)){ - createError("'"+path+"' | invalid color!") + const checkHexColor = (value,path) => { + if (!/^#[a-fA-F0-9]{3,6}$/.test(value)){ + if (value.length < 4) return createError("'"+path+"' | hex color too short! (example: #123abc)") + if (value.length > 7) return createError("'"+path+"' | hex color too long! (example: #123abc)") + createError("'"+path+"' | invalid color! (example: #123abc)") + } + } + + /**@param {String} value @param {String} path */ + const checkEmbedColor = (value,path) => { + if (!['DEFAULT','WHITE','AQUA','GREEN','BLUE','YELLOW','PURPLE','LUMINOUS_VIVID_PINK','FUCHSIA','GOLD','ORANGE','RED','GREY','DARKER_GREY','NAVY','DARK_AQUA','DARK_GREEN','DARK_BLUE','DARK_PURPLE','DARK_VIVID_PINK','DARK_GOLD','DARK_ORANGE','DARK_RED','DARK_GREY','LIGHT_GREY','DARK_NAVY','BLURPLE','GREYPLE','DARK_BUT_NOT_BLACK','NOT_QUITE_BLACK','RANDOM'].includes(value)){ + return createError("'"+path+"' | invalid color, must be a hex code or default color (more info in the wiki)") } } @@ -229,7 +238,11 @@ exports.checker = async () => { checkType(config.bot_name,"string","bot_name") - checkColor(config.main_color,"main_color") + if (config.main_color.startsWith("#")){ + checkHexColor(config.main_color,"main_color") + }else{ + checkEmbedColor(config.main_color,"main_color") + } checkDiscord("serverid",config.server_id,"server_id") checkToken(config.auth_token) checkDiscordArray("roleid",config.main_adminroles,"main_adminroles") diff --git a/core/dynamicdatabase/cleardata.js b/core/dynamicdatabase/cleardata.js index c63acfd..be11d68 100644 --- a/core/dynamicdatabase/cleardata.js +++ b/core/dynamicdatabase/cleardata.js @@ -23,14 +23,14 @@ ask() const runClear = async () => { const chalk = await (await import("chalk")).default - console.log(chalk.blue("You can get a node.js warning below, just ignore that, it's not important!")) + //console.log(chalk.blue("You can get a node.js warning below, just ignore that, it's not important!")) const dataPaths = ["./storage/dynamicDB"] var index = 0 dataPaths.forEach((path) => { try { - fs.rmdirSync(path,{recursive:true,force:true}) + fs.rmSync(path,{recursive:true,force:true}) }catch{ //console.log(path,"doesn't exist") } diff --git a/core/dynamicdatabase/storage.js b/core/dynamicdatabase/storage.js index 7405466..7fa0482 100644 --- a/core/dynamicdatabase/storage.js +++ b/core/dynamicdatabase/storage.js @@ -17,16 +17,16 @@ module.exports = db ** NOT READY YET ** must be dynamic ** =============================*/ -const LocalStorage = require("node-localstorage") - -const ticketStorage = new LocalStorage.LocalStorage("./storage/tickets") -exports.ticketStorage = ticketStorage - -const userTicketStorage = new LocalStorage.LocalStorage("./storage/userTickets") -exports.userTicketStorage = userTicketStorage - -const transcriptStorage = new LocalStorage.LocalStorage("./storage/transcripts") -exports.transcriptStorage = transcriptStorage +//const LocalStorage = require("node-localstorage") +// +//const ticketStorage = new LocalStorage.LocalStorage("./storage/tickets") +//exports.ticketStorage = ticketStorage +// +//const userTicketStorage = new LocalStorage.LocalStorage("./storage/userTickets") +//exports.userTicketStorage = userTicketStorage +// +//const transcriptStorage = new LocalStorage.LocalStorage("./storage/transcripts") +//exports.transcriptStorage = transcriptStorage //const ticketNumberStorage = new LocalStorage.LocalStorage("./storage/ticketNumbers") //exports.ticketNumberStorage = ticketNumberStorage diff --git a/core/slashSystem/slashEnable.js b/core/slashSystem/slashEnable.js index 7fbb6bb..bef52fe 100644 --- a/core/slashSystem/slashEnable.js +++ b/core/slashSystem/slashEnable.js @@ -13,7 +13,9 @@ module.exports = async () => { var choices = [] ids.forEach((id) => { const option = getoptions.getOptionsById(id) - choices.push({name:option.name,value:option.id}) + if (option.type == "ticket"){ + choices.push({name:option.name,value:option.id}) + } }) /**@type {[{name:String,value:String}]} */ diff --git a/core/ticketOpener.js b/core/ticketOpener.js index 9cdb293..32f9deb 100644 --- a/core/ticketOpener.js +++ b/core/ticketOpener.js @@ -34,16 +34,18 @@ module.exports = () => { }else return if (getconfigoptions.getTicketValues("id").includes(customId)){ - + + //ticketoptions from config + const currentTicketOptions = getconfigoptions.getOptionsById(customId) + + if (currentTicketOptions == false || currentTicketOptions.type != "ticket") return interaction.reply({content:"This button is not a ticket!"}) + 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 (storage.get("ticketStorage",interaction.member.id) == null || storage.get("ticketStorage",interaction.member.id) == "false"|| Number(storage.get("ticketStorage",interaction.member.id)) < config.system.max_allowed_tickets){ try{ @@ -139,6 +141,7 @@ module.exports = () => { storage.set("userTicketStorage",ticketChannel.id,interaction.member.id) var ticketEmbed = new discord.MessageEmbed() + //.setColor(config.main_color) .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!*") diff --git a/index.js b/index.js index 193d7b6..cdd360c 100644 --- a/index.js +++ b/index.js @@ -6,9 +6,13 @@ exports.client = client client.setMaxListeners(20) -//change to FALSE on release -const isDev = false -//!!!!!!!!!!! +if (process.argv[2]){ + if (process.argv[2].endsWith("d")){ + var isDev = true + console.log("starting in dev mode...") + }else{var isDev = false} +}else{var isDev = false} + if (isDev){ try { @@ -22,12 +26,14 @@ exports.config = config client.on('ready',async () => { const chalk = await (await import("chalk")).default - if (process.argv[2] != "slash"){ + if (!process.argv[2].startsWith("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}) } + + await client.guilds.cache.find((g) => g.id == config.server_id).members.fetch() }else{ console.log(chalk.red("STARTING IN ")+chalk.blue("SLASH MODE")+chalk.red("...")) console.log("logs:\n================") @@ -46,9 +52,11 @@ client.on('ready',async () => { } }) -require("./core/checker").checker() +if (!isDev){ + require("./core/checker").checker() +} -if (process.argv[2] != "slash"){ +if (process.argv[2] && !process.argv[2].startsWith("slash")){ var storage = require('./core/dynamicdatabase/storage') exports.storage = storage @@ -67,11 +75,6 @@ if (process.argv[2] != "slash"){ require("./core/closebuttons")() require("./core/reactionRoles")() - /** - * We need: - * - checker.js - */ - } diff --git a/package.json b/package.json index 21b6826..9a07851 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-ticket", - "version": "2.0.0", + "version": "2.1.0", "description": "This is an open-source discord ticket bot, you can configure it and it comes with cool features like a transcript.", "main": "index.js", "scripts": {