v2.1.0 push 3

This commit is contained in:
DJj123dj
2022-06-09 20:23:34 +02:00
parent 1728c3653a
commit 89a44f3f2f
19 changed files with 148 additions and 58 deletions
+2 -1
View File
@@ -8,4 +8,5 @@ devConfig4.json
devConfig5.json devConfig5.json
.DS_Store .DS_Store
openticketdebug.txt openticketdebug.txt
developerChangelog.md developerChangelog.md
storage/dynamicDB/
+5 -4
View File
@@ -2,6 +2,7 @@ const discord = require('discord.js')
const bot = require('../index') const bot = require('../index')
const client = bot.client const client = bot.client
const config = bot.config const config = bot.config
const log = bot.errorLog.log
module.exports = () => { module.exports = () => {
client.on("messageCreate",msg => { client.on("messageCreate",msg => {
@@ -20,10 +21,10 @@ module.exports = () => {
msg.channel.permissionOverwrites.create(user.id, { VIEW_CHANNEL:true, ADD_REACTIONS:true,ATTACH_FILES:true, EMBED_LINKS:true, SEND_MESSAGES:true}) msg.channel.permissionOverwrites.create(user.id, { VIEW_CHANNEL:true, ADD_REACTIONS:true,ATTACH_FILES:true, EMBED_LINKS:true, SEND_MESSAGES:true})
msg.channel.send({embeds:[bot.errorLog.success("User Added!",user.tag+" is added to this ticket")]}) msg.channel.send({embeds:[bot.errorLog.success("User Added!",user.tag+" is added to this ticket")]})
if (config.logs){console.log("[system] added user to ticket (name:"+user.username+",ticket:"+msg.channel.name+")")}
var loguser = msg.mentions.users.first() var loguser = msg.mentions.users.first()
if (config.logs){console.log("[command] "+config.prefix+"add "+loguser.username+" (user:"+msg.author.username+")")} log("command","someone used the 'add' command",[{key:"user",value:msg.author.tag}])
log("system","user added to ticket",[{key:"user",value:msg.author.tag},{key:"ticket",value:msg.channel.name},{key:"added_user",value:loguser.tag}])
}) })
}) })
@@ -47,10 +48,10 @@ module.exports = () => {
interaction.channel.permissionOverwrites.create(user.id, { VIEW_CHANNEL:true, ADD_REACTIONS:true,ATTACH_FILES:true, EMBED_LINKS:true, SEND_MESSAGES:true}) interaction.channel.permissionOverwrites.create(user.id, { VIEW_CHANNEL:true, ADD_REACTIONS:true,ATTACH_FILES:true, EMBED_LINKS:true, SEND_MESSAGES:true})
interaction.reply({embeds:[bot.errorLog.success("User Added!",user.tag+" is added to this ticket")]}) interaction.reply({embeds:[bot.errorLog.success("User Added!",user.tag+" is added to this ticket")]})
if (config.logs){console.log("[system] added user to ticket (name:"+user.username+",ticket:"+interaction.channel.name+")")}
var loguser = user var loguser = user
if (config.logs){console.log("[command] "+config.prefix+"add "+loguser.username+" (user:"+interaction.user.username+")")} log("command","someone used the 'add' command",[{key:"user",value:interaction.user.tag}])
log("system","user added to ticket",[{key:"user",value:interaction.user.tag},{key:"ticket",value:interaction.channel.name},{key:"added_user",value:loguser.tag}])
}) })
+3 -2
View File
@@ -2,6 +2,7 @@ const discord = require('discord.js')
const bot = require('../index') const bot = require('../index')
const client = bot.client const client = bot.client
const config = bot.config const config = bot.config
const log = bot.errorLog.log
module.exports = () => { module.exports = () => {
client.on("messageCreate",msg => { client.on("messageCreate",msg => {
@@ -24,7 +25,7 @@ module.exports = () => {
msg.channel.send({embeds:[bot.errorLog.success("Close this ticket!","You can close this ticket by clicking on the button below!")],components:[closebutton]}) msg.channel.send({embeds:[bot.errorLog.success("Close this ticket!","You can close this ticket by clicking on the button below!")],components:[closebutton]})
console.log("[system] closed a ticket via command") log("command","someone used the 'close' command",[{key:"user",value:msg.author.tag}])
}) })
@@ -51,7 +52,7 @@ module.exports = () => {
interaction.reply({embeds:[bot.errorLog.success("Close this ticket!","You can close this ticket by clicking on the button below!")],components:[closebutton]}) interaction.reply({embeds:[bot.errorLog.success("Close this ticket!","You can close this ticket by clicking on the button below!")],components:[closebutton]})
console.log("[system] closed a ticket via command") log("command","someone used the 'close' command",[{key:"user",value:interaction.user.tag}])
}) })
}) })
+3 -2
View File
@@ -2,6 +2,7 @@ const discord = require('discord.js')
const bot = require('../index') const bot = require('../index')
const client = bot.client const client = bot.client
const config = bot.config const config = bot.config
const log = bot.errorLog.log
module.exports = () => { module.exports = () => {
client.on("messageCreate",msg => { client.on("messageCreate",msg => {
@@ -24,7 +25,7 @@ module.exports = () => {
msg.channel.send({embeds:[bot.errorLog.success("Delete this ticket!","You can delete this ticket by clicking on the button below!")],components:[closebutton]}) msg.channel.send({embeds:[bot.errorLog.success("Delete this ticket!","You can delete this ticket by clicking on the button below!")],components:[closebutton]})
console.log("[system] deleted a ticket via command") log("command","someone used the 'delete' command",[{key:"user",value:msg.author.tag}])
}) })
@@ -51,7 +52,7 @@ module.exports = () => {
interaction.reply({embeds:[bot.errorLog.success("Delete this ticket!","You can delete this ticket by clicking on the button below!")],components:[closebutton]}) interaction.reply({embeds:[bot.errorLog.success("Delete this ticket!","You can delete this ticket by clicking on the button below!")],components:[closebutton]})
console.log("[system] deleted a ticket via command") log("command","someone used the 'close' command",[{key:"user",value:interaction.user.tag}])
}) })
}) })
+3 -1
View File
@@ -2,6 +2,7 @@ const discord = require('discord.js')
const bot = require('../index') const bot = require('../index')
const client = bot.client const client = bot.client
const config = bot.config const config = bot.config
const log = bot.errorLog.log
module.exports = () => { module.exports = () => {
const helpEmbed = new discord.MessageEmbed() const helpEmbed = new discord.MessageEmbed()
@@ -22,7 +23,7 @@ module.exports = () => {
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("rename")){ 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("rename")){
msg.channel.send({embeds:[helpEmbed]}) msg.channel.send({embeds:[helpEmbed]})
if (config.logs){console.log("[command] "+config.prefix+"ticket help (user:"+msg.author.username+")")} log("command","someone used the 'help' command",[{key:"user",value:msg.author.tag}])
} }
}) })
@@ -31,5 +32,6 @@ module.exports = () => {
if (interaction.commandName != "help") return if (interaction.commandName != "help") return
interaction.reply({embeds:[helpEmbed]}) interaction.reply({embeds:[helpEmbed]})
log("command","someone used the 'help' command",[{key:"user",value:interaction.user.tag}])
}) })
} }
+7 -4
View File
@@ -2,6 +2,7 @@ const discord = require('discord.js')
const bot = require('../index') const bot = require('../index')
const client = bot.client const client = bot.client
const config = bot.config const config = bot.config
const log = bot.errorLog.log
module.exports = () => { module.exports = () => {
client.on("messageCreate",msg => { client.on("messageCreate",msg => {
@@ -20,10 +21,11 @@ module.exports = () => {
msg.channel.permissionOverwrites.delete(user.id) msg.channel.permissionOverwrites.delete(user.id)
msg.channel.send({embeds:[bot.errorLog.success("User removed!",user.tag+" is removed from this ticket")]}) msg.channel.send({embeds:[bot.errorLog.success("User removed!",user.tag+" is removed from this ticket")]})
if (config.logs){console.log("[system] deleted user from ticket (name:"+user.username+",ticket:"+msg.channel.name+")")}
var loguser = msg.mentions.users.first() var loguser = msg.mentions.users.first()
if (config.logs){console.log("[command] "+config.prefix+"remove "+loguser.username+" (user:"+msg.author.username+")")}
log("command","someone used the 'remove' command",[{key:"user",value:msg.author.tag}])
log("system","user removed from ticket",[{key:"user",value:msg.author.tag},{key:"ticket",value:msg.channel.name},{key:"removed_user",value:loguser.tag}])
}) })
}) })
@@ -48,10 +50,11 @@ module.exports = () => {
interaction.channel.permissionOverwrites.delete(user.id) interaction.channel.permissionOverwrites.delete(user.id)
interaction.reply({embeds:[bot.errorLog.success("User removed!",user.tag+" is removed from this ticket")]}) interaction.reply({embeds:[bot.errorLog.success("User removed!",user.tag+" is removed from this ticket")]})
if (config.logs){console.log("[system] removed user from ticket (name:"+user.username+",ticket:"+interaction.channel.name+")")}
var loguser = user var loguser = user
if (config.logs){console.log("[command] "+config.prefix+"remove "+loguser.username+" (user:"+interaction.user.username+")")}
log("command","someone used the 'remove' command",[{key:"user",value:interaction.user.tag}])
log("system","user removed from ticket",[{key:"user",value:interaction.user.tag},{key:"ticket",value:interaction.channel.name},{key:"removed_user",value:loguser.tag}])
}) })
+5 -2
View File
@@ -2,6 +2,7 @@ const discord = require('discord.js')
const bot = require('../index') const bot = require('../index')
const client = bot.client const client = bot.client
const config = bot.config const config = bot.config
const log = bot.errorLog.log
module.exports = () => { module.exports = () => {
client.on("messageCreate",msg => { client.on("messageCreate",msg => {
@@ -35,7 +36,8 @@ module.exports = () => {
msg.channel.setName(prefix+newname) msg.channel.setName(prefix+newname)
msg.channel.send({embeds:[bot.errorLog.success("The name has changed!","Warning: you can only change the channel name 2 times per minute!\n(this is due discord rate limits)")]}) msg.channel.send({embeds:[bot.errorLog.success("The name has changed!","Warning: you can only change the channel name 2 times per minute!\n(this is due discord rate limits)")]})
console.log("[system] renamed a ticket via command") log("command","someone used the 'rename' command",[{key:"user",value:msg.author.tag}])
log("system","ticket renamed",[{key:"user",value:msg.author.tag},{key:"ticket",value:name},{key:"newname",value:newname}])
}) })
@@ -72,7 +74,8 @@ module.exports = () => {
interaction.channel.setName(prefix+newname) interaction.channel.setName(prefix+newname)
interaction.reply({embeds:[bot.errorLog.success("The name has changed!","Warning: you can only change the channel name 2 times per minute!\n(this is due discord rate limits)")]}) interaction.reply({embeds:[bot.errorLog.success("The name has changed!","Warning: you can only change the channel name 2 times per minute!\n(this is due discord rate limits)")]})
console.log("[system] renamed a ticket via command") log("command","someone used the 'rename' command",[{key:"user",value:interaction.user.tag}])
log("system","ticket renamed",[{key:"user",value:interaction.user.tag},{key:"ticket",value:name},{key:"newname",value:newname}])
}) })
}) })
+4 -5
View File
@@ -2,6 +2,7 @@ const discord = require('discord.js')
const bot = require('../index') const bot = require('../index')
const client = bot.client const client = bot.client
const config = bot.config const config = bot.config
const log = bot.errorLog.log
/** ============================= /** =============================
** NOT READY YET ** NOT READY YET
@@ -16,7 +17,7 @@ module.exports = () => {
client.on("messageCreate", msg => { client.on("messageCreate", msg => {
if (msg.content.startsWith(config.prefix+"msg")){ if (msg.content.startsWith(config.prefix+"msg"||config.prefix+"message")){
if (config.main_adminroles.some((item)=>{return msg.member.roles.cache.has(item)}) == false){ if (config.main_adminroles.some((item)=>{return msg.member.roles.cache.has(item)}) == false){
msg.channel.send({embeds:[bot.errorLog.noPermsMessage]}) msg.channel.send({embeds:[bot.errorLog.noPermsMessage]})
return return
@@ -32,8 +33,7 @@ module.exports = () => {
msg.channel.send({embeds:[embed],components:componentRows}) msg.channel.send({embeds:[embed],components:componentRows})
if (config.logs){console.log("[command] "+config.prefix+"ticket msg (user:"+msg.author.username+")")} log("command","someone used the 'msg' command",[{key:"user",value:msg.author.tag},{key:"id",value:id}])
if (config.logs){console.log("[system] created ticket message")}
} }
}) })
@@ -56,8 +56,7 @@ module.exports = () => {
interaction.reply({content:"The embed is in the message below!"}) interaction.reply({content:"The embed is in the message below!"})
interaction.channel.send({embeds:[embed],components:componentRows}) interaction.channel.send({embeds:[embed],components:componentRows})
if (config.logs){console.log("[command] "+config.prefix+"ticket msg (user:"+interaction.member.user.username+")")} log("command","someone used the 'msg' command",[{key:"user",value:interaction.user.tag},{key:"id",value:id}])
if (config.logs){console.log("[system] created ticket message")}
}) })
} }
+2 -2
View File
@@ -5,7 +5,6 @@
"auth_token":"auth token", "auth_token":"auth token",
"main_adminroles":["discord role id"], "main_adminroles":["discord role id"],
"prefix":"!ticket ", "prefix":"!ticket ",
"logs":true,
"languagefile":"english.json (currently not working)", "languagefile":"english.json (currently not working)",
"credits":true, "credits":true,
@@ -42,7 +41,8 @@
"channelprefix":"question-", "channelprefix":"question-",
"category":"category id", "category":"category id",
"message":"You created a ticket!", "message":"You created a ticket!",
"enableDMMessage":true "enableDMMessage":true,
"ticketmessage":"The staff will help you soon!\n\n*Click on the button below to close the ticket!*"
}, },
{ {
+7 -2
View File
@@ -132,13 +132,15 @@ exports.checker = async () => {
createError("'"+path+"/id' | option id can't contain space characters!") createError("'"+path+"/id' | option id can't contain space characters!")
} }
if (option.id.length > 20){ if (option.id.length > 20){
createError("'"+path+"/id' | option id max lenght is 20") createError("'"+path+"/id' | option id max lenght is 20!")
} }
//name //name
checkType(option.name,"string",path+"/name") checkType(option.name,"string",path+"/name")
if (option.name.length > 100){ if (option.name.length > 100){
createWarn("'"+path+"/name' | if your name is too long it maybe doesn't look so good!") createWarn("'"+path+"/name' | if your name is too long it maybe doesn't look so good!")
}else if (option.name.length < 1){
createError("'"+path+"/name' | there is no name!")
} }
//description //description
@@ -193,6 +195,10 @@ exports.checker = async () => {
//enableDMmessage //enableDMmessage
checkType(option.enableDMMessage,"boolean",path+"/enableDMMessage") checkType(option.enableDMMessage,"boolean",path+"/enableDMMessage")
//ticketmessage
checkType(option.ticketmessage,"string",path+"/ticketmessage")
}else if (type == "website"){ }else if (type == "website"){
//url //url
checkType(option.url,"string",path+"/url") checkType(option.url,"string",path+"/url")
@@ -247,7 +253,6 @@ exports.checker = async () => {
checkToken(config.auth_token) checkToken(config.auth_token)
checkDiscordArray("roleid",config.main_adminroles,"main_adminroles") checkDiscordArray("roleid",config.main_adminroles,"main_adminroles")
checkString(config.prefix,1,15,"prefix","prefix") checkString(config.prefix,1,15,"prefix","prefix")
checkType(config.logs,"boolean","logs")
//languagefile (comming soon) //languagefile (comming soon)
+48 -2
View File
@@ -42,14 +42,13 @@ exports.invalidIdChooseFromList = (list) => {
return x return x
} }
//seves
exports.notInATicket = new embed() exports.notInATicket = new embed()
.setColor("RED") .setColor("RED")
.setTitle(":x: You are not in a ticket! :x:") .setTitle(":x: You are not in a ticket! :x:")
.setDescription("This command doesn't work outside tickets!") .setDescription("This command doesn't work outside tickets!")
/**@param {String} message @param {String} title */
exports.success = (title,message) => { exports.success = (title,message) => {
var x = new embed() var x = new embed()
.setColor(config.main_color) .setColor(config.main_color)
@@ -57,4 +56,51 @@ exports.success = (title,message) => {
.setDescription(message) .setDescription(message)
return x return x
}
/**@param {String} message @param {String} title */
exports.warning = (title,message) => {
var x = new embed()
.setColor("ORANGE")
.setTitle(":warning: "+title+" :warning:")
.setDescription(message)
return x
}
/**@param {String} message the message @param {String} title the title @param {String} emoji an discord emoji @param {discord.ColorResolvable} color the embed color*/
exports.custom = (title,message,emoji,color) => {
var x = new embed()
.setColor(color)
.setTitle(emoji+" "+title+" "+emoji)
.setDescription(message)
return x
}
/**
*
* @param {"system"|"command"|"info"} type
* @param {String} message
* @param {[{key:String,value:String}]} params
*/
exports.log = async (type,message,params) => {
const chalk = await loadChalk()
var paramstring = ""
if (params){
if (params.length > 0){
params.forEach((p) => {
paramstring = paramstring+p.key+": "+p.value+" "
})
}
}
const parameters = params ? "("+paramstring+")" : " "
if (type == "command"){
console.log(chalk.green("[command] ")+message+" "+chalk.yellow(parameters))
}else if (type == "info"){
console.log(chalk.blue("[info] ")+message+" "+chalk.yellow(parameters))
}else if (type == "system"){
console.log(chalk.green("[system] ")+message+" "+chalk.yellow(parameters))
}
} }
+5 -3
View File
@@ -3,7 +3,7 @@ const config = bot.config
/** /**
* @param {Number} index * @param {Number} index
* @param {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"adminroles"|"channelprefix"|"category"|"message"|"enableDMMessage"} value * @param {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"adminroles"|"channelprefix"|"category"|"message"|"enableDMMessage"|"ticketmessage"} value
*/ */
exports.getTicketValue = (index,value) => { exports.getTicketValue = (index,value) => {
if (value == "id"){ if (value == "id"){
@@ -29,7 +29,7 @@ exports.getRoleValue = (index,value) => {
} }
/** /**
* @param {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"adminroles"|"channelprefix"|"category"|"message"|"enableDMMessage"} value * @param {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"adminroles"|"channelprefix"|"category"|"message"|"enableDMMessage"|"ticketmessage"} value
*/ */
exports.getTicketValues = (value) => { exports.getTicketValues = (value) => {
var result = [] var result = []
@@ -55,7 +55,7 @@ exports.getRoleValue = (index,value) => {
} }
/** /**
* @param {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"roles"|"mode"|"enableDMMessage"} value * @param {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"roles"|"mode"|"enableDMMessage""} value
*/ */
exports.getRoleValues = (value) => { exports.getRoleValues = (value) => {
var result = [] var result = []
@@ -79,6 +79,7 @@ class TicketOptions {
this.category = "" this.category = ""
this.message = "" this.message = ""
this.enableDMMessage = true this.enableDMMessage = true
this.ticketmessage = ""
} }
} }
/** /**
@@ -110,5 +111,6 @@ exports.exportedOptionClass = class {
this.category = "" this.category = ""
this.message = "" this.message = ""
this.enableDMMessage = true this.enableDMMessage = true
this.ticketmessage = ""
} }
} }
+15 -9
View File
@@ -2,6 +2,7 @@ const discord = require('discord.js')
const bot = require('../index') const bot = require('../index')
const client = bot.client const client = bot.client
const config = bot.config const config = bot.config
const log = bot.errorLog.log
const storage = bot.storage const storage = bot.storage
@@ -14,12 +15,13 @@ module.exports = async () => {
interaction.deferUpdate() interaction.deferUpdate()
const optionid = interaction.customId.split("newR")[1] if (interaction.customId.startsWith("newR")){
if (!optionid){ const optionid = interaction.customId.split("newR")[1]
interaction.reply({content:"This button doesn't exist anymore"}) if (!optionid){
return interaction.reply({embeds:[bot.errorLog.serverError("This role doesn't exist anymore!")]})
return
}
} }
try { try {
const option = require("./utils/getButton").getOption(optionid) const option = require("./utils/getButton").getOption(optionid)
@@ -30,21 +32,25 @@ module.exports = async () => {
if (mode == "add"){ if (mode == "add"){
option.roles.forEach((role) => { option.roles.forEach((role) => {
interaction.guild.members.cache.find(u => u.id == user.id).roles.add(role) interaction.guild.members.cache.find(u => u.id == user.id).roles.add(role)
console.log("[system] added role",role,"to",user.user.tag)
log("system","added role (reaction roles)",[{key:"user",value:interaction.user.tag},{key:"role",value:role}])
}) })
}else if (mode == "remove"){ }else if (mode == "remove"){
option.roles.forEach((role) => { option.roles.forEach((role) => {
interaction.guild.members.cache.find(u => u.id == user.id).roles.remove(role) interaction.guild.members.cache.find(u => u.id == user.id).roles.remove(role)
console.log("[system] removed role",role,"from",user.user.tag)
log("system","removed role (reaction roles)",[{key:"user",value:interaction.user.tag},{key:"role",value:role}])
}) })
}else if (mode == "add&remove"){ }else if (mode == "add&remove"){
option.roles.forEach((role) => { option.roles.forEach((role) => {
if (interaction.guild.members.cache.find(u => u.id == user.id).roles.cache.has(role)){ if (interaction.guild.members.cache.find(u => u.id == user.id).roles.cache.has(role)){
interaction.guild.members.cache.find(u => u.id == user.id).roles.remove(role) interaction.guild.members.cache.find(u => u.id == user.id).roles.remove(role)
console.log("[system] removed role",role,"from",user.user.tag)
log("system","added role (reaction roles)",[{key:"user",value:interaction.user.tag},{key:"role",value:role}])
}else { }else {
interaction.guild.members.cache.find(u => u.id == user.id).roles.add(role) interaction.guild.members.cache.find(u => u.id == user.id).roles.add(role)
console.log("[system] added role",role,"to",user.user.tag)
log("system","removed role (reaction roles)",[{key:"user",value:interaction.user.tag},{key:"role",value:role}])
} }
}) })
} }
+8 -4
View File
@@ -2,6 +2,7 @@ const discord = require('discord.js')
const bot = require('../index') const bot = require('../index')
const client = bot.client const client = bot.client
const config = bot.config const config = bot.config
const log = bot.errorLog.log
const storage = bot.storage const storage = bot.storage
@@ -42,7 +43,7 @@ exports.closeTicket = async (interaction,prefix,mode) => {
if (mode == "delete"){ if (mode == "delete"){
interaction.channel.delete() interaction.channel.delete()
if (config.logs){console.log("[system] deleted a ticket (name:"+interaction.channel.name+",user:"+interaction.user.username+")")} log("system","deleted a ticket",[{key:"user",value:interaction.user.tag},{key:"ticket",value:interaction.channel.name}])
if (!isDatabaseError) storage.set("ticketStorage",getuserID,Number(storage.get("ticketStorage",getuserID)) - 1) if (!isDatabaseError) storage.set("ticketStorage",getuserID,Number(storage.get("ticketStorage",getuserID)) - 1)
}else if (mode == "close"){ }else if (mode == "close"){
@@ -85,10 +86,13 @@ exports.closeTicket = async (interaction,prefix,mode) => {
.setTitle("Closed this ticket!") .setTitle("Closed this ticket!")
.setDescription("Only admins can now talk in this ticket!\n\n*Click on the button below to delete 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]}) interaction.channel.send({embeds:[embed],components:[closeButtonRow]})
log("system","closed a ticket",[{key:"user",value:interaction.user.tag},{key:"ticket",value:interaction.channel.name}])
}else if (mode == "deletenotranscript"){ }else if (mode == "deletenotranscript"){
enableTranscript = false enableTranscript = false
interaction.channel.delete() interaction.channel.delete()
if (config.logs){console.log("[system] deleted a ticket (name:"+interaction.channel.name+",user:"+interaction.user.username+")")} log("system","deleted a ticket",[{key:"user",value:interaction.user.tag},{key:"ticket",value:interaction.channel.name}])
if (!isDatabaseError) storage.set("ticketStorage",getuserID,Number(storage.get("ticketStorage",getuserID)) - 1) if (!isDatabaseError) storage.set("ticketStorage",getuserID,Number(storage.get("ticketStorage",getuserID)) - 1)
} }
@@ -98,7 +102,7 @@ exports.closeTicket = async (interaction,prefix,mode) => {
if (config.system.enable_transcript || config.system.enable_DM_transcript){ if (config.system.enable_transcript || config.system.enable_DM_transcript){
var fileattachment = await require("./transcript").createTranscript(channelmessages) var fileattachment = await require("./transcript").createTranscript(channelmessages)
if (fileattachment == false){console.log("[transcript] internal error: no transcript is created!");return} if (fileattachment == false){log("system","internal error: transcript is not created!");return}
} }
if (config.system.enable_transcript){ if (config.system.enable_transcript){
@@ -146,7 +150,7 @@ exports.runThis = () => {
var fileattachment = await require("./transcript").createTranscript(channelmessages) var fileattachment = await require("./transcript").createTranscript(channelmessages)
if (fileattachment == false){ if (fileattachment == false){
console.log("[transcript] internal error: no transcript is created!") log("system","internal error: transcript is not created!")
interaction.channel.send({embeds:[bot.errorLog.serverError("Something went wrong while making the transcript!**\nPlease try again another time!")]}) interaction.channel.send({embeds:[bot.errorLog.serverError("Something went wrong while making the transcript!**\nPlease try again another time!")]})
return return
} }
+20 -11
View File
@@ -2,6 +2,7 @@ const discord = require('discord.js')
const bot = require('../index') const bot = require('../index')
const client = bot.client const client = bot.client
const config = bot.config const config = bot.config
const log = bot.errorLog.log
const getconfigoptions = require("./getoptions") const getconfigoptions = require("./getoptions")
const storage = bot.storage const storage = bot.storage
@@ -32,28 +33,36 @@ module.exports = () => {
}else if (interaction.isButton()){ }else if (interaction.isButton()){
var customId = interaction.customId var customId = interaction.customId
}else return }else return
if (interaction.customId.startsWith("newT")){
const optionid = interaction.customId.split("newT")[1]
if (!optionid){
interaction.reply({embeds:[bot.errorLog.serverError("This ticket doesn't exist anymore!")]})
return
}
}
if (getconfigoptions.getTicketValues("id").includes(customId)){ if (getconfigoptions.getTicketValues("id").includes(customId)){
//ticketoptions from config //ticketoptions from config
const currentTicketOptions = getconfigoptions.getOptionsById(customId) const currentTicketOptions = getconfigoptions.getOptionsById(customId)
if (currentTicketOptions == false || currentTicketOptions.type != "ticket") return interaction.reply({content:"This button is not a ticket!"}) if (currentTicketOptions == false || currentTicketOptions.type != "ticket") return interaction.reply({embeds:[bot.errorLog.serverError("This option is not a ticket but another type!")]})
if (interaction.isButton()){ if (interaction.isButton()){
interaction.deferUpdate() interaction.deferUpdate()
}else if (interaction.isCommand()){ }else if (interaction.isCommand()){
interaction.reply({content:"Your ticket is created!"}) interaction.reply({embeds:[bot.errorLog.success("Ticket Created!","Your ticket is created, you can detect it by a ping!")]})
} }
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){ 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{ try{
if (config.system.enable_DM_Messages){ if (config.system.enable_DM_Messages){
interaction.member.send({content:currentTicketOptions.message}) interaction.member.send({embeds:[bot.errorLog.custom("New Ticket!",currentTicketOptions.message,":ticket:",config.main_color)]})
} }
} }
catch{console.log("[system] can't send DM to member, member doesn't allow dm's")} catch{log("system","can't send DM to member, member doesn't allow dm's")}
@@ -141,28 +150,28 @@ module.exports = () => {
storage.set("userTicketStorage",ticketChannel.id,interaction.member.id) storage.set("userTicketStorage",ticketChannel.id,interaction.member.id)
var ticketEmbed = new discord.MessageEmbed() var ticketEmbed = new discord.MessageEmbed()
//.setColor(config.main_color)
.setColor(config.main_color) .setColor(config.main_color)
.setTitle("You created a ticket!") .setTitle(currentTicketOptions.name)
.setDescription("The staff will help you soon!\n\n*Click on the button below to close the ticket!*") if (currentTicketOptions.ticketmessage.length > 0) ticketEmbed.setDescription(currentTicketOptions.ticketmessage)
ticketChannel.send({ ticketChannel.send({
content:"<@"+interaction.member.id+"> @everyone", content:"<@"+interaction.member.id+"> @here",
embeds:[ticketEmbed], embeds:[ticketEmbed],
components:[closeButton] components:[closeButton]
}).then(firstmsg => { }).then(firstmsg => {
firstmsg.pin() firstmsg.pin()
}) })
if (config.logs){console.log("[system] created a new ticket (name:"+logsname+",user:"+interaction.user.username+")")}
log("system","created new ticket",[{key:"ticket",value:ticketName},{key:"user",value:interaction.user.tag}])
}) })
}else{ }else{
try { try {
if (config.system.enable_DM_Messages){ if (config.system.enable_DM_Messages){
interaction.member.send("you already have the maximum number of tickets allowed!") interaction.member.send({embeds:[bot.errorLog.warning("Max amount reached!","You reached the maximum number of tickets allowed!\nSo you can't create a new one!")]})
} }
} }
catch{console.log("[system] can't send DM to member, member doesn't allow dm's")} catch{log("system","can't send DM to member, member doesn't allow dm's")}
} }
+1 -1
View File
@@ -30,7 +30,7 @@ exports.createTranscript = async (messagecollection) => {
const filebuff = Buffer.from(filestring,"utf-8") const filebuff = Buffer.from(filestring,"utf-8")
return new discord.MessageAttachment(filebuff,"transcript.txt") return new discord.MessageAttachment(filebuff,"transcript.txt")
}catch(err){ }catch(err){
console.log(err) console.log("[error] "+err)
return false return false
} }
} }
+1
View File
@@ -87,6 +87,7 @@ exports.rawButtonData = class {
this.channelprefix = "" this.channelprefix = ""
this.category = "" this.category = ""
this.message = "" this.message = ""
this.ticketmessage = ""
} }
} }
+8 -2
View File
@@ -24,16 +24,22 @@ if (isDev){
}else{var config = require('./config.json')} }else{var config = require('./config.json')}
exports.config = config exports.config = config
exports.errorLog = require("./core/errorLogSystem") exports.errorLog = require("./core/errorLogSystem")
const log = this.errorLog.log
client.on('ready',async () => { client.on('ready',async () => {
const chalk = await (await import("chalk")).default const chalk = await (await import("chalk")).default
if (!process.argv[2].startsWith("slash")){ if (!process.argv[2].startsWith("slash")){
console.log(chalk.green("open-ticket ready!")) console.log(chalk.red("WELCOME TO OPEN TICKET!"))
if (config.logs){console.log(chalk.white("\n\nlogs:\n============"))} log("info","open ticket ready")
console.log(chalk.blue("\n\nlogs:")+"\n============")
if (config.status.enabled){ if (config.status.enabled){
client.user.setActivity(config.status.text,{type:config.status.type}) client.user.setActivity(config.status.text,{type:config.status.type})
} }
log("system","bot logged in!")
await client.guilds.cache.find((g) => g.id == config.server_id).members.fetch() await client.guilds.cache.find((g) => g.id == config.server_id).members.fetch()
}else{ }else{
console.log(chalk.red("STARTING IN ")+chalk.blue("SLASH MODE")+chalk.red("...")) console.log(chalk.red("STARTING IN ")+chalk.blue("SLASH MODE")+chalk.red("..."))
+1 -1
View File
@@ -14,7 +14,7 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"chalk": "^5.0.1", "chalk": "^5.0.1",
"discord.js": "^13.6.0", "discord.js": "^13.8.0",
"express": "^4.17.1", "express": "^4.17.1",
"node": "^16.10.0", "node": "^16.10.0",
"node-localstorage": "^2.2.1" "node-localstorage": "^2.2.1"