From e4c1e2559e922a92f61ca78e25f4f17b03e741dc Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Wed, 5 Oct 2022 20:25:35 +0200 Subject: [PATCH] 3.0 public beta 4 --- README.md | 1 + commands/claim.js | 80 +++++++++++++++++++++ commands/help.js | 6 +- commands/unclaim.js | 77 ++++++++++++++++++++ config.json | 15 +++- core/api/api.json | 13 +++- core/api/modules/base.js | 26 +------ core/checker.js | 14 +++- core/errorLogSystem.js | 2 +- core/interactionHandlers/embeds/commands.js | 25 +++++++ core/languageManager.js | 1 + core/slashSystem/slashEnable.js | 35 ++++++++- core/ticketActions/ticketCloser.js | 10 +++ core/ticketActions/ticketOpener.js | 2 +- core/utils/configParser.js | 6 +- index.js | 38 ++++++---- language/arabic.json | 2 + language/custom.json | 2 + language/czech.json | 2 + language/dutch.json | 2 + language/english.json | 2 + language/french.json | 2 + language/german.json | 2 + language/italian.json | 77 ++++++++++++++++++++ language/portuguese.json | 2 + language/romanian.json | 2 + language/spanish.json | 2 + 27 files changed, 397 insertions(+), 51 deletions(-) create mode 100644 commands/claim.js create mode 100644 commands/unclaim.js create mode 100644 language/italian.json diff --git a/README.md b/README.md index bd5c6fc..26810d9 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ This is an open-source discord ticket bot, you can configure it and it comes wit - josuens14 - M4 - David. +- Maurizio ## features - discord interaction buttons diff --git a/commands/claim.js b/commands/claim.js new file mode 100644 index 0000000..ff17fc2 --- /dev/null +++ b/commands/claim.js @@ -0,0 +1,80 @@ +const discord = require('discord.js') +const bot = require('../index') +const client = bot.client +const config = bot.config +const log = bot.errorLog.log +const l = bot.language +const permsChecker = require("../core/utils/permisssionChecker") + +const APIEvents = require("../core/api/modules/events") +const DISABLE = require("../core/api/api.json").disable + +module.exports = () => { + bot.errorLog.log("debug","COMMANDS: loaded claim.js") + + if (!DISABLE.commands.text.claim) client.on("messageCreate",msg => { + if (!msg.content.startsWith(config.prefix+"claim")) return + var user = msg.mentions.users.first() + + const claimingUser = user ? user : msg.author + + if (!msg.guild) return + if (!permsChecker.command(msg.author.id,msg.guild.id)){ + permsChecker.sendUserNoPerms(msg.author) + return + } + + msg.channel.messages.fetchPinned().then(msglist => { + var firstmsg = msglist.last() + if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]}) + const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description) + const ticketId = hiddendata.data.find(d => d.key == "type").value + + + //msg.channel.send({embeds:[bot.embeds.commands.claimEmbed(claimingUser,msg.author)]}) + msg.channel.send({embeds:[bot.errorLog.warning("Coming soon!","This feature isn't ready yet!\nIt will become active in the next update!")]}) + + var loguser = claimingUser + log("command","someone used the 'claim' command",[{key:"user",value:msg.author.tag}]) + log("system","user claimed to ticket",[{key:"user",value:msg.author.tag},{key:"ticket",value:msg.channel.name},{key:"claimed_user",value:claimingUser.tag}]) + + const ticketData = require("../core/utils/configParser").getTicketById(ticketId,true) + //APIEvents.onTicketAdd(msg.author,loguser,msg.channel,msg.guild,new Date(),{status:"open",name:msg.channel.name,ticketOptions:ticketData}) + //APIEvents.onCommand("add",permsChecker.command(msg.author.id,msg.guild.id),msg.author,msg.channel,msg.guild,new Date()) + }) + + }) + + if (!DISABLE.commands.slash.claim) client.on("interactionCreate",(interaction) => { + if (!interaction.isChatInputCommand()) return + if (interaction.commandName != "claim") return + const user = interaction.options.getUser("user",false) ? interaction.options.getUser("user",true) : interaction.user + + if (!interaction.guild) return + if (!permsChecker.command(interaction.user.id,interaction.guild.id)){ + permsChecker.sendUserNoPerms(interaction.user) + return + } + + interaction.channel.messages.fetchPinned().then(msglist => { + var firstmsg = msglist.last() + if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.reply({embeds:[bot.errorLog.notInATicket]}) + const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description) + const ticketId = hiddendata.data.find(d => d.key == "type").value + + //interaction.reply({embeds:[bot.embeds.commands.claimEmbed(user,interaction.user)]}) + interaction.reply({embeds:[bot.errorLog.warning("Coming soon!","This feature isn't ready yet!\nIt will become active in the next update!")]}) + + var loguser = user + log("command","someone used the 'claim' command",[{key:"user",value:interaction.user.tag}]) + log("system","user claimed to ticket",[{key:"user",value:interaction.user.tag},{key:"ticket",value:interaction.channel.name},{key:"claimed_user",value:loguser.tag}]) + + const ticketData = require("../core/utils/configParser").getTicketById(ticketId,true) + //APIEvents.onTicketAdd(interaction.user,loguser,interaction.channel,interaction.guild,new Date(),{status:"open",name:interaction.channel.name,ticketOptions:ticketData}) + //APIEvents.onCommand("add",permsChecker.command(interaction.user.id,interaction.guild.id),interaction.user,interaction.channel,interaction.guild,new Date()) + + }) + + + }) +} \ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 47a66fe..9c19abc 100644 --- a/commands/help.js +++ b/commands/help.js @@ -11,13 +11,15 @@ const DISABLE = require("../core/api/api.json").disable module.exports = () => { bot.errorLog.log("debug","COMMANDS: loaded help.js") + const msgName = config.system.showSlashcmdsInHelp ? "message" : "msg" + const prefix = config.system.showSlashcmdsInHelp ? "/" : config.prefix + const helpEmbed = new discord.EmbedBuilder() .setColor(config.main_color) .setTitle("❔ "+l.helpMenu.title) - const prefix = config.prefix const header = config.system.ticket_channel ? l.helpMenu.header1.replace("{0}","<#"+config.system.ticket_channel+">") : l.helpMenu.header2 - helpEmbed.setDescription(header+"`"+prefix+"msg ` ➜ _"+l.helpMenu.msgCmd+"_\n\n`"+prefix+"rename ` ➜ _"+l.helpMenu.renameCmd+"_\n`"+prefix+"close` ➜ _"+l.helpMenu.closeCmd+"_\n`"+prefix+"delete` ➜ _"+l.helpMenu.deleteCmd+"_\n`"+prefix+"reopen` ➜ _"+l.helpMenu.reopenCmd+"_\n\n`"+prefix+"add ` ➜ _"+l.helpMenu.addCmd+"_\n`"+prefix+"remove ` ➜ _"+l.helpMenu.removeCmd+"_`") + helpEmbed.setDescription(header+"`"+prefix+msgName+" ` ➜ _"+l.helpMenu.msgCmd+"_\n\n`"+prefix+"rename ` ➜ _"+l.helpMenu.renameCmd+"_\n`"+prefix+"close` ➜ _"+l.helpMenu.closeCmd+"_\n`"+prefix+"delete` ➜ _"+l.helpMenu.deleteCmd+"_\n`"+prefix+"reopen` ➜ _"+l.helpMenu.reopenCmd+"_\n\n`"+prefix+"add ` ➜ _"+l.helpMenu.addCmd+"_\n`"+prefix+"remove ` ➜ _"+l.helpMenu.removeCmd+"_") if (config.credits) helpEmbed.setFooter({text:"Open-Ticket by DJdj Development | view on github for source code",iconURL:"https://raw.githubusercontent.com/DJj123dj/open-ticket/main/logo.png"}) diff --git a/commands/unclaim.js b/commands/unclaim.js new file mode 100644 index 0000000..be01a4d --- /dev/null +++ b/commands/unclaim.js @@ -0,0 +1,77 @@ +const discord = require('discord.js') +const bot = require('../index') +const client = bot.client +const config = bot.config +const log = bot.errorLog.log +const l = bot.language +const permsChecker = require("../core/utils/permisssionChecker") + +const APIEvents = require("../core/api/modules/events") +const DISABLE = require("../core/api/api.json").disable + +module.exports = () => { + bot.errorLog.log("debug","COMMANDS: loaded unclaim.js") + + if (!DISABLE.commands.text.unclaim) client.on("messageCreate",msg => { + if (!msg.content.startsWith(config.prefix+"unclaim")) return + + if (!msg.guild) return + if (!permsChecker.command(msg.author.id,msg.guild.id)){ + permsChecker.sendUserNoPerms(msg.author) + return + } + + msg.channel.messages.fetchPinned().then(msglist => { + var firstmsg = msglist.last() + if (firstmsg == undefined || firstmsg.author.id != client.user.id) return msg.channel.send({embeds:[bot.errorLog.notInATicket]}) + const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description) + const ticketId = hiddendata.data.find(d => d.key == "type").value + + + //msg.channel.send({embeds:[bot.embeds.commands.unclaimEmbed(msg.author)]}) + msg.channel.send({embeds:[bot.errorLog.warning("Coming soon!","This feature isn't ready yet!\nIt will become active in the next update!")]}) + + var loguser = msg.author + log("command","someone used the 'unclaim' command",[{key:"user",value:msg.author.tag}]) + log("system","user unclaimed from ticket",[{key:"user",value:msg.author.tag},{key:"ticket",value:msg.channel.name},{key:"unclaimed_user",value:msg.author.tag}]) + + const ticketData = require("../core/utils/configParser").getTicketById(ticketId,true) + //APIEvents.onTicketAdd(msg.author,loguser,msg.channel,msg.guild,new Date(),{status:"open",name:msg.channel.name,ticketOptions:ticketData}) + //APIEvents.onCommand("add",permsChecker.command(msg.author.id,msg.guild.id),msg.author,msg.channel,msg.guild,new Date()) + }) + + }) + + if (!DISABLE.commands.slash.unclaim) client.on("interactionCreate",(interaction) => { + if (!interaction.isChatInputCommand()) return + if (interaction.commandName != "unclaim") return + const user = interaction.user + + if (!interaction.guild) return + if (!permsChecker.command(interaction.user.id,interaction.guild.id)){ + permsChecker.sendUserNoPerms(interaction.user) + return + } + + interaction.channel.messages.fetchPinned().then(msglist => { + var firstmsg = msglist.last() + if (firstmsg == undefined || firstmsg.author.id != client.user.id) return interaction.reply({embeds:[bot.errorLog.notInATicket]}) + const hiddendata = bot.hiddenData.readHiddenData(firstmsg.embeds[0].description) + const ticketId = hiddendata.data.find(d => d.key == "type").value + + //interaction.reply({embeds:[bot.embeds.commands.unclaimEmbed(interaction.user)]}) + interaction.reply({embeds:[bot.errorLog.warning("Coming soon!","This feature isn't ready yet!\nIt will become active in the next update!")]}) + + var loguser = user + log("command","someone used the 'unclaim' command",[{key:"user",value:interaction.user.tag}]) + log("system","user unclaimed from ticket",[{key:"user",value:interaction.user.tag},{key:"ticket",value:interaction.channel.name},{key:"unclaimed_user",value:loguser.tag}]) + + const ticketData = require("../core/utils/configParser").getTicketById(ticketId,true) + //APIEvents.onTicketAdd(interaction.user,loguser,interaction.channel,interaction.guild,new Date(),{status:"open",name:interaction.channel.name,ticketOptions:ticketData}) + //APIEvents.onCommand("add",permsChecker.command(interaction.user.id,interaction.guild.id),interaction.user,interaction.channel,interaction.guild,new Date()) + + }) + + + }) +} \ No newline at end of file diff --git a/config.json b/config.json index d346174..729f66c 100644 --- a/config.json +++ b/config.json @@ -24,7 +24,9 @@ "enable_transcript":false, "enable_DM_transcript":false, - "transcript_channel":"channel id" + "transcript_channel":"channel id", + + "showSlashcmdsInHelp":false }, "options":[ @@ -44,8 +46,15 @@ "enableDmOnOpen":true, "ticketmessage":"The staff will help you soon!\n\n*Click on the button below to close the ticket!*", - "enableThumbnail":false, - "thumbnailUrl":"https://www.example.com/catmemes/cat.png" + "thumbnail":{ + "enable":false, + "url":"https://www.example.com/catmemes/cat.png" + }, + + "closedCategory":{ + "enable":false, + "id":"category id" + } }, { diff --git a/core/api/api.json b/core/api/api.json index f3456a0..6832775 100644 --- a/core/api/api.json +++ b/core/api/api.json @@ -1,6 +1,7 @@ { "version":"1.0.0", "enableAPIdebug":false, + "enableAPIconsolelogs":false, "info":"If you turn these switches to true, then the feature will be turned OFF!", "info2":"You can use this to disable some features you don't want!", @@ -26,7 +27,9 @@ "new":false, "add":false, "remove":false, - "rename":false + "rename":false, + "claim":false, + "unclaim":false }, "slash":{ "help":false, @@ -37,12 +40,18 @@ "new":false, "add":false, "remove":false, - "rename":false + "rename":false, + "claim":false, + "unclaim":false } }, "checkerjs":{ "token":false, "all":false + }, + "debug":{ + "all":false, + "debuglogs":false } } } \ No newline at end of file diff --git a/core/api/modules/base.js b/core/api/modules/base.js index 1f96c22..8d4921e 100644 --- a/core/api/modules/base.js +++ b/core/api/modules/base.js @@ -1,28 +1,8 @@ -const discord = require('discord.js') -const bot = require("../../../index") -const client = bot.client -const config = bot.config -const log = bot.errorLog.log -const l = bot.language -const storage = bot.storage - /** FOR DEVELOPERS ONLY!! - * Don't change anything in this file, read the api documentation first! - * look into "api docs.md" for the docs! + * Don't change anything in this file before reading the documentation! + * visit the api documentation at https://docs.openticket.dj-dj.be */ -//used when creating plugins! -exports.enableApiLogs = false - -//DOESN'T WORK YET -//this is used when embedding open ticket into another bot exports.embeddedMode = false -exports.clientLocation = require("../../../index").client - -/** !! WARNING !! - * Only edit or extend the code when you know what you are doing! - * If open ticket crashes while you change the code, then we can't help you! - * - * DO IT ON YOUR OWN RISK! - */ \ No newline at end of file +exports.clientLocation = require("../../../index").client \ No newline at end of file diff --git a/core/checker.js b/core/checker.js index 4fff2a1..afae5f9 100644 --- a/core/checker.js +++ b/core/checker.js @@ -217,6 +217,17 @@ exports.checker = async () => { //ticketmessage checkType(option.ticketmessage,"string",path+"/ticketmessage") + //thumbnail + checkType(option.thumbnail.enable,"boolean",path/"/thumbnail/enable") + checkType(option.thumbnail.url,"string",path/"/thumbnail/url") + + //closedCategory + checkType(option.closedCategory.enable,"boolean",path/"/closedCategory/enable") + checkType(option.closedCategory.id,"string",path/"/closedCategory/id") + if (option.closedCategory.enable){ + checkDiscord("roleid",option.closedCategory.id,path+"/closedCategory/id") + } + }else if (type == "website"){ //url checkType(option.url,"string",path+"/url") @@ -339,7 +350,7 @@ exports.checker = async () => { //languagefile checkType(config.languagefile,"string","languagefile") const lf = config.languagefile - if (!lf.startsWith("custom") && !lf.startsWith("english") && !lf.startsWith("dutch") && !lf.startsWith("romanian") && !lf.startsWith("german") && !lf.startsWith("arabic") && !lf.startsWith("spanish") && !lf.startsWith("portuguese") && !lf.startsWith("french")){ + if (!lf.startsWith("custom") && !lf.startsWith("english") && !lf.startsWith("dutch") && !lf.startsWith("romanian") && !lf.startsWith("german") && !lf.startsWith("arabic") && !lf.startsWith("spanish") && !lf.startsWith("portuguese") && !lf.startsWith("french") && !lf.startsWith("italian")){ createError("'languagefile' | invalid language, more info in the wiki") } @@ -382,6 +393,7 @@ exports.checker = async () => { if (config.system.enable_transcript){ checkDiscord("channelid",config.system.transcript_channel,"system/transcript_channel") } + checkType(config.system.showSlashcmdsInHelp,"boolean","system/showSlashcmdsInHelp") //options diff --git a/core/errorLogSystem.js b/core/errorLogSystem.js index 6f57323..8c03515 100644 --- a/core/errorLogSystem.js +++ b/core/errorLogSystem.js @@ -125,7 +125,7 @@ exports.log = async (type,message,params) => { }else if (ptype == "system"){ console.log(chalk.green("[system] ")+message+" "+chalk.yellow(parameters)) }else if (ptype == "api"){ - if (require("./api/modules/base").enableApiLogs == true){ + if (require("./api/api.json").enableAPIconsolelogs == true){ console.log(chalk.red("[api v"+require("./api/api.json").version+"] ")+message+" "+chalk.yellow(parameters)) } ptype = "api v"+require("./api/api.json").version diff --git a/core/interactionHandlers/embeds/commands.js b/core/interactionHandlers/embeds/commands.js index ad9a747..990bd23 100644 --- a/core/interactionHandlers/embeds/commands.js +++ b/core/interactionHandlers/embeds/commands.js @@ -90,6 +90,31 @@ exports.renameEmbed = (renamer,newname) => { .setFooter({text:reopener.tag,iconURL:reopener.displayAvatarURL()}) } +/** + * + * @param {discord.User} claimer + * @param {discord.User} user + * @returns {discord.EmbedBuilder} + */ + exports.claimEmbed = (claimer,user) => { + return new embed() + .setTitle("📌 "+l.commands.claimTitle.replace("{0}",claimer.username)) + .setColor(mc) + .setFooter({text:user.tag,iconURL:user.displayAvatarURL()}) +} + +/** + * + * @param {discord.User} unclaimer + * @returns {discord.EmbedBuilder} + */ + exports.unclaimEmbed = (unclaimer) => { + return new embed() + .setTitle("🆓 "+l.commands.unclaimTitle) + .setColor(mc) + .setFooter({text:unclaimer.tag,iconURL:unclaimer.displayAvatarURL()}) +} + /** * * @param {Boolean} done diff --git a/core/languageManager.js b/core/languageManager.js index e8d4854..31641de 100644 --- a/core/languageManager.js +++ b/core/languageManager.js @@ -15,6 +15,7 @@ else if (config.languagefile.startsWith("romanian")) localLanguage = require(".. else if (config.languagefile.startsWith("arabic")) localLanguage = require("../language/arabic.json") else if (config.languagefile.startsWith("spanish")) localLanguage = require("../language/spanish.json") else if (config.languagefile.startsWith("portuguese")) localLanguage = require("../language/portuguese.json") +else if (config.languagefile.startsWith("italian")) localLanguage = require("../language/italian.json") const errorLog = async () => { diff --git a/core/slashSystem/slashEnable.js b/core/slashSystem/slashEnable.js index e7ace19..17a9a57 100644 --- a/core/slashSystem/slashEnable.js +++ b/core/slashSystem/slashEnable.js @@ -32,10 +32,10 @@ module.exports = async () => { //process.stdout.write("[status] there are "+chalk.blue("0 out of 10")+" commands ready! (this can take up to 40 seconds)") setInterval(() => { process.stdout.cursorTo(0) - process.stdout.write("[status] there are "+chalk.blue(readystats+" out of 10")+" commands ready! (this can take up to 40 seconds)") - if (readystats >= 10){ + process.stdout.write("[status] there are "+chalk.blue(readystats+" out of 12")+" commands ready! (this can take up to 40 seconds)") + if (readystats >= 12){ console.log(chalk.green("\nready!")) - console.log(chalk.bgBlue("you can now start the bot with 'npm start'!")) + console.log(chalk.blue("you can now start the bot with "+chalk.bgBlue("'npm start'")+"!")) process.exit(1) } },100) @@ -202,4 +202,33 @@ module.exports = async () => { readystats++ }) + //claim + client.application.commands.create({ + name:"claim", + description:"Claim this ticket / claim it for someone else.", + defaultPermission:true, + type:act.ChatInput, + options:[ + { + name:"user", + type:acot.User, + required:false, + description:"The user to claim for." + } + ] + + },sid).then(() => { + readystats++ + }) + + //unclaim + client.application.commands.create({ + name:"unclaim", + description:"Unclaim this ticket.", + defaultPermission:true, + type:act.ChatInput + },sid).then(() => { + readystats++ + }) + } \ No newline at end of file diff --git a/core/ticketActions/ticketCloser.js b/core/ticketActions/ticketCloser.js index 588cfbe..c43854e 100755 --- a/core/ticketActions/ticketCloser.js +++ b/core/ticketActions/ticketCloser.js @@ -154,6 +154,16 @@ exports.NEWcloseTicket = async (member,channel,prefix,mode,reason,nomessage) => if (!ticketData) return + if (ticketData.closedCategory.enable){ + /**@type {discord.CategoryChannel} */ + const category = guild.channels.cache.find(c => c.id == ticketData.closedCategory.id && c.type == discord.ChannelType.GuildCategory) + try { + channel.setParent(category) + }catch{ + bot.errorLog.log("system","failed to move channel to new category!") + } + } + /** * @type {String[]} */ diff --git a/core/ticketActions/ticketOpener.js b/core/ticketActions/ticketOpener.js index d79b9cc..f6264c4 100755 --- a/core/ticketActions/ticketOpener.js +++ b/core/ticketActions/ticketOpener.js @@ -185,7 +185,7 @@ module.exports = () => { ticketEmbed.setDescription(hiddendata) } - if (currentTicketOptions.enableThumbnail) ticketEmbed.setThumbnail(currentTicketOptions.thumbnailUrl) + if (currentTicketOptions.thumbnail.enable) ticketEmbed.setThumbnail(currentTicketOptions.thumbnail.url) ticketChannel.send({ content:"<@"+interaction.member.id+"> @here", diff --git a/core/utils/configParser.js b/core/utils/configParser.js index dc05ac5..20797cd 100644 --- a/core/utils/configParser.js +++ b/core/utils/configParser.js @@ -6,7 +6,7 @@ const l = bot.language //================== //OTTicketOptions -/**@typedef {{id: String,name: String,description: String,icon: String,label: String,type: "ticket"|"role"|"website",color: "red"|"green"|"blue"|"gray",adminroles: String[],channelprefix: String,category: String,message: String,enableDmOnOpen: Boolean,ticketmessage: String, enableThumbnail:Boolean, thumbnailUrl:String}} OTTicketOptions */ +/**@typedef {{id: String,name: String,description: String,icon: String,label: String,type: "ticket"|"role"|"website",color: "red"|"green"|"blue"|"gray",adminroles: String[],channelprefix: String,category: String,message: String,enableDmOnOpen: Boolean,ticketmessage: String, thumbnail:{enable:Boolean,url:String}, closedCategory:{enable:Boolean,id:String}}} OTTicketOptions */ //OTRoleOptions /**@typedef {{id: String,name: String,description: String,icon: String,label: String,type: "ticket"|"role"|"website",color:"red"|"green"|"blue"|"gray"|"none",roles:String[],mode:"add&remove"|"remove"|"add",enableDmOnOpen:Boolean}} OTRoleOptions */ @@ -19,7 +19,7 @@ const l = bot.language /**@typedef {{id: string, name: string, description: string, dropdown: boolean, enableFooter: boolean, footer: string, enableThumbnail: boolean, thumbnail: string, enableCustomColor: boolean, color: string, options: string[], enableTicketExplaination: boolean, enableMaxTicketsWarning: boolean}} OTConfigMessage*/ //StringOptions -/**@typedef {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"adminroles"|"channelprefix"|"category"|"message"|"enableDmOnOpen"|"ticketmessage"|"enableThumbnail"|"thumbnailUrl"} OTTicketStringOptions */ +/**@typedef {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"adminroles"|"channelprefix"|"category"|"message"|"enableDmOnOpen"|"ticketmessage"|"thumbnail"|"closedCategory"} OTTicketStringOptions */ /**@typedef {"id"|"name"|"description"|"icon"|"label"|"type"|"color"|"roles"|"mode"|"enableDmOnOpen"} OTRoleStringOptions */ /**@typedef {"id"|"name"|"description"|"icon"|"label"|"type"|"url"} OTWebsiteStringOptions */ @@ -169,7 +169,7 @@ this.messageType = {} //OTAllOptions -/**@typedef {{id: String,name: String,description: String,icon: String,label: String,type: "ticket"|"role"|"website",color:"red"|"green"|"blue"|"gray"|"none",roles:String[],mode:"add&remove"|"remove"|"add",adminroles: String[],channelprefix: String,category: String,message: String,enableDmOnOpen: Boolean,ticketmessage: String, enableThumbnail:Boolean, thumbnailUrl:String,url:String}} OTAllOptions */ +/**@typedef {{id: String,name: String,description: String,icon: String,label: String,type: "ticket"|"role"|"website",color:"red"|"green"|"blue"|"gray"|"none",roles:String[],mode:"add&remove"|"remove"|"add",adminroles: String[],channelprefix: String,category: String,message: String,enableDmOnOpen: Boolean,ticketmessage: String, thumbnail:{enable:Boolean,url:String}, url:String, closedCategory:{enable:Boolean,id:String}}} OTAllOptions */ /** * diff --git a/index.js b/index.js index 20b47e6..8a09539 100644 --- a/index.js +++ b/index.js @@ -12,17 +12,24 @@ const discord = require("discord.js") const fs = require('fs') const {GatewayIntentBits,Partials} = discord -const client = new discord.Client({ - intents:[ - GatewayIntentBits.DirectMessages, - GatewayIntentBits.GuildInvites, - GatewayIntentBits.GuildMembers, - GatewayIntentBits.GuildMessages, - GatewayIntentBits.Guilds, - GatewayIntentBits.MessageContent - ], - partials:[Partials.Channel,Partials.Message] -}) +const APIBase = require("./core/api/modules/base") +if (APIBase.embeddedMode){ + var tempClient = APIBase.clientLocation +}else{ + var tempClient = new discord.Client({ + intents:[ + GatewayIntentBits.DirectMessages, + GatewayIntentBits.GuildInvites, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.Guilds, + GatewayIntentBits.MessageContent + ], + partials:[Partials.Channel,Partials.Message] + }) +} +/**@type {discord.Client} */ +const client = tempClient exports.client = client client.setMaxListeners(50) if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","created client") @@ -183,6 +190,8 @@ if (process.argv[2] && process.argv[2].startsWith("slash")){ require("./commands/add")() require("./commands/remove")() require("./commands/reopen")() + require("./commands/claim")() + require("./commands/unclaim")() this.errorLog.log("debug","LOADING CORE") //core @@ -198,14 +207,19 @@ if (process.argv[2] && process.argv[2].startsWith("slash")){ this.errorLog.log("debug","loading api") const APIEvents = require("./core/api/modules/events") +const APIConfig = require("./core/api/api.json") const debugLog = (debugString) => { + if (!APIConfig.disable.debug.all && !APIConfig.disable.debug.debuglogs){ const content = fs.existsSync("./openticketdebug.txt") ? fs.readFileSync("./openticketdebug.txt").toString() : "==========================\n\n==========================" fs.writeFileSync("./openticketdebug.txt",content+"\nDEBUG: "+debugString) + } } const errorLog = (errorString,stack) => { + if (!APIConfig.disable.debug.all){ const content = fs.existsSync("./openticketdebug.txt") ? fs.readFileSync("./openticketdebug.txt").toString() : "==========================\n\n==========================" fs.writeFileSync("./openticketdebug.txt",content+"\nERROR: "+errorString+" STACK: "+stack) + } } this.errorLog.log("debug","OT error system loaded successfully") @@ -225,5 +239,5 @@ process.on("uncaughtException",async (error,origin) => { APIEvents.onError(error.name+": "+error.message,new Date()) }) -client.login(config.auth_token) +if (!APIBase.embeddedMode) client.login(config.auth_token) this.errorLog.log("debug","login with token") \ No newline at end of file diff --git a/language/arabic.json b/language/arabic.json index 4f98097..5f0391d 100644 --- a/language/arabic.json +++ b/language/arabic.json @@ -25,6 +25,8 @@ "closeTitle": "تم أغلاق التكت!", "deleteTitle": " جاري حذف التكت...", "reopenTitle": "إعادة فتح التكت!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", "ticketWarning": "هذا الأمبد موجود بالفعل في الرسالة بالأسفل!", "maxTicketWarning": "**تحذير:** _يمكنك فقط فتح {0} تكت في الوقت!_" diff --git a/language/custom.json b/language/custom.json index 9496227..90a5419 100644 --- a/language/custom.json +++ b/language/custom.json @@ -25,6 +25,8 @@ "closeTitle":"Closed this ticket!", "deleteTitle":"Deleting this ticket...", "reopenTitle":"Re-Opened this ticket!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", "ticketWarning":"The embed is in the message below!", "maxTicketWarning":"**Warning:** _You can only create {0} ticket(s) at a time!_" diff --git a/language/czech.json b/language/czech.json index 93bdeb4..f65e72c 100644 --- a/language/czech.json +++ b/language/czech.json @@ -25,6 +25,8 @@ "closeTitle":"Zavři tento ticket!", "deleteTitle":"Smaž tento ticket!", "reopenTitle":"Znovu otevři ticket!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", "ticketWarning":"The embed is in the message below!", "maxTicketWarning":"**Varovaní:** _Můžeš si vytvořit použe {0} ticket(s) v jednu chvíli!_" diff --git a/language/dutch.json b/language/dutch.json index 4bd61eb..91bcb83 100644 --- a/language/dutch.json +++ b/language/dutch.json @@ -25,6 +25,8 @@ "closeTitle":"Ticket gesloten!", "deleteTitle":"Ticket aan het verwijderen...", "reopenTitle":"Ticket heropend!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", "ticketWarning":"De embed is in het bericht hier onder!", "maxTicketWarning":"**Waarschuwing:** _Je kan maar {0} ticket(s) tegelijkertijd maken!_" diff --git a/language/english.json b/language/english.json index 9496227..90a5419 100644 --- a/language/english.json +++ b/language/english.json @@ -25,6 +25,8 @@ "closeTitle":"Closed this ticket!", "deleteTitle":"Deleting this ticket...", "reopenTitle":"Re-Opened this ticket!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", "ticketWarning":"The embed is in the message below!", "maxTicketWarning":"**Warning:** _You can only create {0} ticket(s) at a time!_" diff --git a/language/french.json b/language/french.json index fcac829..19287fd 100644 --- a/language/french.json +++ b/language/french.json @@ -25,6 +25,8 @@ "closeTitle":"Fermé ce ticket!", "deleteTitle":"Suppression de ce ticket...", "reopenTitle":"A rouvert ce ticket!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", "ticketWarning":"L'intégration est dans le message ci-dessous!", "maxTicketWarning":"**Attention :** _Vous ne pouvez créer que {0} ticket(s) à la fois !_" diff --git a/language/german.json b/language/german.json index 01d29a7..db19f7e 100644 --- a/language/german.json +++ b/language/german.json @@ -25,6 +25,8 @@ "closeTitle":"Closed this ticket!", "deleteTitle":"Deleting this ticket...", "reopenTitle":"Re-Opened this ticket!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", "ticketWarning":"The embed is in the message below!", "maxTicketWarning":"**Warning:** _You can only create {0} ticket(s) at a time!_" diff --git a/language/italian.json b/language/italian.json new file mode 100644 index 0000000..9ee12f1 --- /dev/null +++ b/language/italian.json @@ -0,0 +1,77 @@ +{ + "errors":{ + "missingArgsTitle":"Argomenti non validi!", + "missingArgsDescription":"Argomento mancante", + "noPermsTitle":"Permessi mancanti!", + "noPermsDescription":"Hai bisogno del permesso `ADMINISTRATOR` e essere nella lista dei ruoli accettati!", + "noPermsDelete":"Solo gli amministratori possono chiudere un ticket!", + "chooseFromListTitle":"ID non valido", + "chooseFromListDescription":"Scegli uno degli ID sotto:", + "boterror":"Errore del bot!", + "notInTicketTitle":"Non sei in un ticket!", + "notInTicketDescription":"Questo comando non funziona fuori da un ticket!", + "ticketDoesntExist":"Questo ticket non esiste più!", + "roleDoesntExist":"Questo ruolo non esiste più!", + "anotherOption":"Questa opzione non è di un ticket!", + "maxAmountTitle":"Massimo numero raggiunto!", + "maxAmountDescription":"Hai raggiunto il massimo numero di ticket consentiti!\nNon puoi crearne altri!", + "somethingWentWrong":"**Qualcosa è andato storto!**\nPerfavore riprova un'altra volta!", + "somethingWentWrongTranscript":"Qualcosa è andata storta durante la trascrizione!**\nPerfavore riprova un'altra volta!" + }, + "commands":{ + "userAddedTitle":"Aggiunto {0} al ticket!", + "userRemovedTitle":"Rimosso {0} da questo ticket!", + "renameTitle":"Cambia il nome in {0}!", + "closeTitle":"Chiudo questo ticket!", + "deleteTitle":"Eliminando questo ticket...", + "reopenTitle":"Ri-Aperto questo ticket!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", + + "ticketWarning":"L'embed è nel messaggio sotto!", + "maxTicketWarning":"**Attenzione:** _Tu puoi creare solo {0} ticket(s) per volta!_" + }, + "helpMenu":{ + "title":"Comandi disponibili:", + "header1":"**Vai a {0} per creare un ticket!**\n\n", + "header2":"**Esegui il comando `/new` o `/ticket` per creare un ticket!**\n\n", + + "msgCmd":"Crea un embed con pulsanti. (solo amministratori)", + "renameCmd":"Rinomina un ticket. (senza spazi)", + "closeCmd":"Chiudi un ticket.", + "deleteCmd":"Elimina un ticket.", + "addCmd":"Aggiungi un membro al ticket.", + "removeCmd":"Rimuovi un membro dal ticket.", + "reopenCmd":"Riapri un ticket dopo averlo chiuso." + }, + "buttons":{ + "close":"Chiudi il ticket", + "delete":"Elimina il ticket", + "reopen":"Riapri il ticket", + "sendTranscript":"Trascrizione" + }, + "messages":{ + "reopenTitle":"Riaperto questo ticket!", + "reopenDescription":"Sentiti libero di parlare di nuovo!", + "closedTitle":"Chiudo questo ticket!", + "closedDescription":"Solo gli amministratori possono parlare in questo ticket ora!\n\n*Clicca sul bottone sotto per chiudere o riaprire questo ticket!*", + "createdTitle":"Ticket creato!", + "createdDescription":"Il tuo ticket è stato creato, puoi capirlo dal ping!", + + "newTicketDmTitle":"Nuovo ticket!", + "closedTicketDmTitle":"Ticket chiuso!", + "deletedTicketDmTitle":"Ticket eliminato!", + "closedTicketDmDescription":"Il tuo ticket è chiuso!", + "deletedTicketDmDescription":"Il tuo ticket è stato eliminato!", + "reopenTicketDmTitle":"Ticket riaperto!", + "reopenTicketDmDescription":"Il tuo ticket è stato riaperto!", + "newTranscriptTitle":"Un nuova trascrizione è qui!", + "hereIsTheTranscript":"Qui è la trascrizione:", + + "chooseCategory":"scegli una categoria:", + "gettingdeleted":"Il ticket sta per essere chiuso...", + + "none":"nessuno", + "reason":"motivo" + } +} \ No newline at end of file diff --git a/language/portuguese.json b/language/portuguese.json index 3106d2c..ff9afe9 100644 --- a/language/portuguese.json +++ b/language/portuguese.json @@ -25,6 +25,8 @@ "closeTitle":"Fechado este ticket!", "deleteTitle":"Excluindo este ticket...", "reopenTitle":"Reabriu este ticket!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", "ticketWarning":"A incorporação está na mensagem abaixo!", "maxTicketWarning":"**Cuidado:** _Você só pode criar {0} ticket(s) de cada vez!!_" diff --git a/language/romanian.json b/language/romanian.json index 42f906d..a644b86 100644 --- a/language/romanian.json +++ b/language/romanian.json @@ -25,6 +25,8 @@ "closeTitle":"Ticket inchis!", "deleteTitle":"Se sterge ticket-ul...", "reopenTitle":"Ticket Re-deschis!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", "ticketWarning":"Embed-ul se afla in mesajul de mai jos!", "maxTicketWarning":"**Avertizare:** _Poti creea doar {0} tickete active!_" diff --git a/language/spanish.json b/language/spanish.json index 44246fd..ff0d98a 100644 --- a/language/spanish.json +++ b/language/spanish.json @@ -25,6 +25,8 @@ "closeTitle":"Cerró este ticket!", "deleteTitle":"Eliminando este ticket...", "reopenTitle":"Re-abrió este boleto!", + "claimTitle":"This ticket is now claimed to {0}", + "unclaimTitle":"This ticket isn't claimed anymore!", "ticketWarning":"La inserción está en el mensaje a continuación!", "maxTicketWarning":"**Advertencia:** _Solo puedes crear {0} ticket(s) a la vez!_"