added dynamic database & everything is now v2.0.0
Changed everything from v1.4.0 to v2.0.0 & added the dynamic database system
This commit is contained in:
@@ -5,7 +5,7 @@ The version above is unstable so if you find bugs, please report them in the dis
|
||||
|
||||
|
||||
# open-ticket
|
||||
[](https://discord.com/invite/26vT9wt3n3) [](https://github.com/DJj123dj/open-ticket/releases/tag/v1.4.0) [](#packages) [](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE)
|
||||
[](https://discord.com/invite/26vT9wt3n3) [](https://github.com/DJj123dj/open-ticket/releases/tag/v2.0.0) [](#packages) [](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!
|
||||
|
||||
@@ -62,7 +62,7 @@ You can also configure your own permissions
|
||||
|
||||
## information
|
||||
|
||||
_v1.4.0 unstable_
|
||||
_v2.0.0 unstable_
|
||||
|
||||
changelog: [click here](./TEMPDOCS.md)
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
# 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!)
|
||||
|
||||
## 1.4.0 beta
|
||||
There is currently no documentation available for open-ticket v1.4.0 beta. So if you want to test it, you need to figure it out on yourself at the moment!
|
||||
## 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!
|
||||
+1
-1
@@ -78,7 +78,7 @@
|
||||
"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",
|
||||
"footer":"Open Ticket v2.0.0 beta - sneakpeak",
|
||||
"enableThumbnail":false,
|
||||
"thumbnail":"https://www.example.com/catmemes/cat.png",
|
||||
"color":"#0075e9",
|
||||
|
||||
@@ -24,7 +24,7 @@ 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!"))
|
||||
const dataPaths = ["./storage/tickets","./storage/transcripts","./storage/userTickets"]
|
||||
const dataPaths = ["./storage/dynamicDB"]
|
||||
|
||||
var index = 0
|
||||
|
||||
@@ -32,20 +32,20 @@ const runClear = async () => {
|
||||
try {
|
||||
fs.rmdirSync(path,{recursive:true,force:true})
|
||||
}catch{
|
||||
console.log(path,"doesn't exist")
|
||||
//console.log(path,"doesn't exist")
|
||||
}
|
||||
setTimeout(() => {
|
||||
try{
|
||||
fs.mkdirSync(path)
|
||||
}catch{
|
||||
console.log(path,"already exists")
|
||||
//console.log(path,"already exists")
|
||||
}
|
||||
index++
|
||||
},500)
|
||||
})
|
||||
|
||||
setInterval(() => {
|
||||
if (index >= 3){
|
||||
if (index >= 1){
|
||||
console.log(chalk.bgGreen("All local data is cleared!"))
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
const localstorage = require("node-localstorage")
|
||||
|
||||
const ls = new localstorage.LocalStorage("./storage/dynamicDB")
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} category
|
||||
* @param {String} id
|
||||
* @param {String} value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
exports.set = (category,id,value) => {
|
||||
ls.setItem(category+"--"+id,value.toString())
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} category
|
||||
* @param {String} id
|
||||
* @returns {String|false}
|
||||
*/
|
||||
exports.get = (category,id) => {
|
||||
const result = ls.getItem(category+"--"+id)
|
||||
if (!result) return false
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} category
|
||||
* @param {String} id
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
exports.delete = (category,id) => {
|
||||
ls.removeItem(category+"--"+id)
|
||||
return true
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
//Do not change this without knowing what you are doing!!
|
||||
const databaseFile = "local"
|
||||
//Do not change this without knowing what you are doing!!
|
||||
|
||||
|
||||
try {
|
||||
var db = require("./dynamicfiles/local")
|
||||
}catch{
|
||||
console.log("I couldn't find the database file! (location: ./core/dynamicdatabase/storage.js:2)")
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
module.exports = db
|
||||
|
||||
|
||||
/** =============================
|
||||
** NOT READY YET
|
||||
** must be dynamic
|
||||
|
||||
+12
-14
@@ -3,9 +3,7 @@ const bot = require('../index')
|
||||
const client = bot.client
|
||||
const config = bot.config
|
||||
|
||||
const ticketStorage = bot.TicketStorage
|
||||
const userTicketStorage = bot.userTicketStorage
|
||||
const transcriptStorage = bot.transcriptStorage
|
||||
const storage = bot.storage
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -27,11 +25,17 @@ exports.closeTicket = async (interaction,prefix,mode) => {
|
||||
const ticketuserarray = interaction.channel.name
|
||||
const ticketusername = ticketuserarray.split(prefix)[1]
|
||||
|
||||
var getuserID = userTicketStorage.getItem(interaction.channel.id)
|
||||
var getuserID = storage.get("userTicketStorage",interaction.channel.id)
|
||||
try {
|
||||
var getusernameStep1 = client.users.cache.find(u => u.id === getuserID)
|
||||
var isDatabaseError = false
|
||||
}catch{
|
||||
var isDatabaseError = true
|
||||
}
|
||||
|
||||
if (!getusernameStep1){
|
||||
console.log(chalk.red("[database error]"),"something went wrong when getting the data in the database.\nNo panic, this error fixes itself!")
|
||||
var isDatabaseError = true
|
||||
}
|
||||
|
||||
var enableTranscript = true
|
||||
@@ -40,10 +44,10 @@ exports.closeTicket = async (interaction,prefix,mode) => {
|
||||
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 (!isDatabaseError) storage.set("ticketStorage",getuserID,Number(storage.get("ticketStorage",getuserID)) - 1)
|
||||
}else if (mode == "close"){
|
||||
var permissionArray = []
|
||||
permissionArray.push({
|
||||
if (!isDatabaseError) permissionArray.push({
|
||||
id:getusernameStep1.id,
|
||||
type:"member",
|
||||
allow:["VIEW_CHANNEL"],
|
||||
@@ -86,7 +90,7 @@ exports.closeTicket = async (interaction,prefix,mode) => {
|
||||
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 (!isDatabaseError) storage.set("ticketStorage",getuserID,Number(storage.get("ticketStorage",getuserID)) - 1)
|
||||
}
|
||||
|
||||
if (enableTranscript == true && mode != "deletenotranscript"){
|
||||
@@ -97,12 +101,6 @@ exports.closeTicket = async (interaction,prefix,mode) => {
|
||||
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)
|
||||
@@ -124,7 +122,7 @@ exports.closeTicket = async (interaction,prefix,mode) => {
|
||||
.setDescription("You can find the transcript in the text file above!")
|
||||
.setFooter({text:"ticket: "+ticketuserarray})
|
||||
|
||||
getusernameStep1.send({
|
||||
if (!isDatabaseError) getusernameStep1.send({
|
||||
embeds:[transcriptEmbed],
|
||||
files:[fileattachment]
|
||||
})
|
||||
|
||||
@@ -4,10 +4,7 @@ const client = bot.client
|
||||
const config = bot.config
|
||||
|
||||
const getconfigoptions = require("./getoptions")
|
||||
|
||||
const ticketStorage = bot.TicketStorage
|
||||
const userTicketStorage = bot.userTicketStorage
|
||||
const transcriptStorage = bot.transcriptStorage
|
||||
const storage = bot.storage
|
||||
|
||||
module.exports = () => {
|
||||
var closeButton = new discord.MessageActionRow()
|
||||
@@ -47,7 +44,7 @@ module.exports = () => {
|
||||
//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){
|
||||
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{
|
||||
if (config.system.enable_DM_Messages){
|
||||
@@ -59,7 +56,7 @@ module.exports = () => {
|
||||
|
||||
|
||||
//update storage
|
||||
ticketStorage.setItem(interaction.member.id,Number(ticketStorage.getItem(interaction.member.id))+1)
|
||||
storage.set("ticketStorage",interaction.member.id,Number(storage.get("ticketStorage",interaction.member.id))+1)
|
||||
var ticketNumber = interaction.member.user.username
|
||||
|
||||
//set ticketName
|
||||
@@ -139,7 +136,7 @@ module.exports = () => {
|
||||
permissionOverwrites:permissionsArray
|
||||
|
||||
}).then((ticketChannel) => {
|
||||
userTicketStorage.setItem(ticketChannel.id,interaction.member.id)
|
||||
storage.set("userTicketStorage",ticketChannel.id,interaction.member.id)
|
||||
|
||||
var ticketEmbed = new discord.MessageEmbed()
|
||||
.setColor(config.main_color)
|
||||
|
||||
@@ -50,10 +50,7 @@ client.on('ready',async () => {
|
||||
|
||||
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
|
||||
exports.storage = storage
|
||||
|
||||
//commands
|
||||
require('./commands/ticket')()
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "open-ticket",
|
||||
"version": "1.3.2",
|
||||
"version": "2.0.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": {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1 +0,0 @@
|
||||
779742674932072469
|
||||
@@ -1 +0,0 @@
|
||||
779742674932072469
|
||||
Reference in New Issue
Block a user