From f608cb71ce87e054895b813ab8807d50da4e6438 Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Wed, 17 May 2023 21:43:57 +0200 Subject: [PATCH] v3.4.0 push 2 (html transcripts v2) --- README.md | 1 + core/checker.js | 2 +- .../communication/compileJsonV2.js | 394 ++++++++++++++++++ core/transcriptSystem/communication/index.js | 11 +- .../communication/mentions.js | 63 +++ .../communication/template.json | 67 --- core/transcriptSystem/info.json | 2 +- core/transcriptSystem/manager.js | 60 ++- language/slashcmds/slash.json | 37 +- language/thai.json | 98 +++++ transcriptconfig.json | 20 +- 11 files changed, 649 insertions(+), 106 deletions(-) create mode 100644 core/transcriptSystem/communication/compileJsonV2.js create mode 100644 core/transcriptSystem/communication/mentions.js delete mode 100644 core/transcriptSystem/communication/template.json create mode 100644 language/thai.json diff --git a/README.md b/README.md index 5e32bc8..e283a0a 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Translators |Turkish |Hydrâelčhâvø#1575 | |Polish |MKevas#8311 | |Slovenian |n1kkec#5341 | +|Thai |Mods HD#0661 | ## links current version: _v3.4.0_ diff --git a/core/checker.js b/core/checker.js index a0fd9d5..13cf23a 100644 --- a/core/checker.js +++ b/core/checker.js @@ -427,7 +427,7 @@ exports.checker = async () => { 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") && !lf.startsWith("italian") && !lf.startsWith("czech") && !lf.startsWith("danish") && !lf.startsWith("russian") && !lf.startsWith("turkish") && !lf.startsWith("polish") && !lf.startsWith("slovenian")){ + 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") && !lf.startsWith("czech") && !lf.startsWith("danish") && !lf.startsWith("russian") && !lf.startsWith("turkish") && !lf.startsWith("polish") && !lf.startsWith("slovenian") && !lf.startsWith("thai")){ createError("'languagefile' | invalid language, more info in the wiki") } diff --git a/core/transcriptSystem/communication/compileJsonV2.js b/core/transcriptSystem/communication/compileJsonV2.js new file mode 100644 index 0000000..2a2acff --- /dev/null +++ b/core/transcriptSystem/communication/compileJsonV2.js @@ -0,0 +1,394 @@ +const discord = require('discord.js') + +const bot = require("../../../index") +const tsconfig = bot.tsconfig +const tsembeds = require("../embeds") +const tsdb = require("../tsdb") + +const otversion = require("../../../package.json").version +const version = require("../info.json").version + +const mentions = require("./mentions").replacementions + +/**@typedef {{background:{enableCustomBackground:Boolean, backgroundModus:"color"|"image", backgroundData:String}, header:{enableCustomHeader:Boolean, decoColor:String, backgroundColor:String, textColor:String}, stats:{enableCustomStats:Boolean, backgroundColor:String, keyTextColor:String, valueTextColor:String, hideBackgroundColor:String, hideTextColor:String}} OTTranscriptStyle} */ +/**@typedef {{name:String, id:String, pfp:String}} OTTranscriptBot */ +/**@typedef {{name:String, id:String, guildname:String, guildid:String, guildinvite:String|false, creatorname:String, creatorid:String, closedbyname:String, closedbyid:String, claimedname:String, claimedid:String, creatorpfp:String, closedbypfp:String, claimedpfp:String, closedtime:Number, openedtime:Number, components:{messages:1, files:1, embeds:1, reactions:1, interactions:{dropdowns:1, buttons:1, total:1}, attachments:{invites:1, images:1, gifs:1, stickers:1}}, roleColors:[{id:String,color:String}] }} OTTranscriptTicket */ +/**@typedef {{author:{name:String, id:String, color:String, pfp:String, bot:Boolean, verifiedBot:Boolean, system:Boolean}, content:String|false, timestamp:Number, type:"normal", important:Boolean, edited:Boolean, embeds:[{title:String|false, description:String|false, authorimg:String|false, authortext:String|false, footerimg:String|false, footertext:String|false, color:String, image:String|false, thumbnail:String|false, url:String|false, fields:[{name:String,value:String,inline:Boolean}]}], attachments:[{type:"FILE", name:String, fileType:String, size:String, url:String}, {type:"FILE:image", name:String, fileType:String, size:String, url:String}, {type:"URL:invite", guildId:String, guildName:String, guildSize:Number, guildOnline:Number, image:String, url:String}, {type:"URL:gif", url:String}, {type:"BUILDIN:sticker", name:String, url:String}], components:[{type:"buttons", buttons:[{type:"interaction"|"url", label:String|false, icon:String|false, color:"gray"|"green"|"red"|"blue", id:String|false, url:String|false, disabled:Boolean}]}, {type:"dropdown", placeholder:String|false, options:[{label:String|false, icon:String|false, description:String|false, id:String|false}]}, {type:"reactions", reactions:[{amount:1, emoji:String, type:"svg"|"image"|"gif"}]}], reply:{type:"reply"|"command"|false, user:{name:String, id:String, color:String, pfp:String, bot:Boolean, verifiedBot:Boolean, system:Boolean}, replyOptions:{content:String, messageId:String, channelId:String, guildId:String}, commandOptions:{interactionName:String, interactionId:String}}}} OTTranscriptMessage */ +/**@typedef {{enabled:Boolean,premiumToken:String, customCredits:{enable:Boolean, replaceText:String, replaceURL:String, enableReportBug:Boolean},customHeaderUrl:{enabled:Boolean, url:String, text:String}, customTranscriptUrl:{enabled:Boolean, name:String}, customFavicon:{enabled:Boolean, image:String},additionalFlags:String[]}} OTTranscriptPremium */ + +/**@typedef {{version:"2", otversion:String, language:String, style:OTTranscriptStyle, bot:OTTranscriptBot, ticket:OTTranscriptTicket, messages:OTTranscriptMessage[], premium:OTTranscriptPremium}} OTTranscriptCompileInput */ + +/**@typedef {{style:OTTranscriptStyle,bot:OTTranscriptBot,ticket:OTTranscriptTicket,premium:OTTranscriptPremium}} OTHTMLDataOption */ + + +/**@param {discord.ButtonStyle} buttonstyle */ +const buttonStyleToColor = (buttonstyle) => { + if (buttonstyle == discord.ButtonStyle.Primary){ + return "blue" + }else if (buttonstyle == discord.ButtonStyle.Secondary){ + return "gray" + }else if (buttonstyle == discord.ButtonStyle.Danger){ + return "red" + }else if (buttonstyle == discord.ButtonStyle.Success){ + return "green" + }else{ + return "gray" + } +} + +/** + * + * @param {discord.Guild} guild + * @param {discord.Channel} channel + * @param {discord.User} user + * @param {discord.Message[]} messagesInv + * @param {OTHTMLDataOption} data + */ +exports.compile = (guild,channel,user,messagesInv,data) => { + const messages = messagesInv.reverse() + var invisibleMessages = 0 + + //MESSAGE STATS COUNTS + var messageAmount = messages.length + var fileAmount = 0 + var embedAmount = 0 + var reactionsAmount = 0 + var interactionAmount = 0 + messages.forEach((msg) => { + fileAmount = fileAmount + Array.from(msg.attachments).length + embedAmount = embedAmount + msg.embeds.length + + msg.reactions.cache.forEach(reaction => { + reactionsAmount = reactionsAmount + reaction.count + }) + if (msg.components && msg.components.length > 0){ + msg.components.forEach((component) => { + if (component.components.length > 0){ + interactionAmount = interactionAmount + component.components.length + }else{ + interactionAmount = interactionAmount+1 + } + + }) + } + }) + + /**@type {OTTranscriptMessage[]} */ + const messagesArray = [] + messages.forEach((msg) => { + if (msg.content || msg.embeds.length > 0 || msg.attachments.toJSON().length > 0 || msg.components.length > 0 || msg.reactions.cache.size > 0){ + + const embedArray = [] + const attachmentArray = [] + const componentsArray = [] + + msg.attachments.forEach((file) => { + attachmentArray.push({ + type:"FILE", + name:file.name, + fileType:file.contentType, + size:Math.round(file.size/1000)+" kb", + url:file.url + }) + }) + + msg.embeds.forEach((embed) => { + embedArray.push({ + title:embed.title || false, + description:embed.description ? mentions(embed.description,guild) : false, + authorimg:((embed.author && embed.author.iconURL) ? embed.author.iconURL : false), + authortext:(embed.author ? embed.author.name : false), + footerimg:((embed.footer && embed.footer.iconURL) ? embed.footer.iconURL : false), + footertext:(embed.footer ? embed.footer.text : false), + color:embed.hexColor, + image:((embed.image && embed.image.url) ? embed.image.url : false), + thumbnail:((embed.thumbnail && embed.thumbnail.url) ? embed.thumbnail.url : false), + url:(embed.url ? embed.url : false), + fields:embed.fields + }) + }) + + const tempreactions = [] + msg.reactions.cache.forEach((reaction) => { + const count = reaction.count + const emoji = reaction.emoji + + if (emoji instanceof discord.GuildEmoji){ + //custom emoji + tempreactions.push({ + amount:count, + emoji:(emoji.url) ? emoji.url : "", + type:(emoji.animated) ? "gif" : "image" + }) + }else if (emoji instanceof discord.ReactionEmoji){ + //build-in emoji + tempreactions.push({ + amount:count, + emoji:emoji.name, + type:"svg" + }) + } + }) + componentsArray.push({ + type: "reactions", + reactions:tempreactions + }) + + msg.components.forEach((actionrow) => { + var isdropdown = false + var actioncomponents = [] + actionrow.components.forEach((comp) => { + if (comp.type == discord.ComponentType.ActionRow || comp.type == discord.ComponentType.TextInput) return + + /** + * type: "buttons"; + buttons: [{ + type: "interaction" | "url"; + label: string | false; + icon: string | false; + color: "gray" | "green" | "red" | "blue"; + id: string | false; + url: string | false; + disabled: boolean; + }]; + }, { + type: "dropdown"; + placeholder: string | false; + options: [{ + label: string | false; + icon: string | false; + description: string | false; + id: string | false; + }]; + }, + */ + if (comp.type == discord.ComponentType.Button){ + actioncomponents.push({ + type: (comp.style == discord.ButtonStyle.Link) ? "url" : "interaction", + label: (comp.label) ? comp.label : false, + icon: (comp.emoji) ? comp.emoji.name : false, + color: buttonStyleToColor(comp.style), + id: comp.customId ? comp.customId : false, + url: (comp.url) ? comp.url : false, + disabled: false + }) + }else{ + isdropdown = true + var drpdwnoptions = [] + /**@type {discord.APISelectMenuOption[]} */ + const dropdownoptions = comp.options + dropdownoptions.forEach((opt) => { + drpdwnoptions.push({ + label: opt.label, + icon: (opt.emoji) ? opt.emoji : false, + description: (opt.description) ? opt.description : false, + id: "hello world :)" + }) + }) + + componentsArray.push({ + type:"dropdown", + placeholder:false, + options:drpdwnoptions + }) + } + }) + + if (!isdropdown){ + componentsArray.push({ + type:"buttons", + buttons:actioncomponents + }) + } + }) + + const important = msg.guild ? (msg.content.includes("<@"+msg.guild.id+">") || msg.content.includes("<@everyone") || msg.content.includes("@here")): false + + const replytype = (msg.interaction) ? "command" : ((msg.reference) ? "reply" : false) + if (replytype == "command"){ + const replycolorRAW = msg.guild.members.cache.find((m) => m.id == msg.interaction.user.id) + const replycolor = (replycolorRAW) ? replycolorRAW.displayHexColor.replace("#000000","#ffffff") : "#ffffff" + var reply = { + type:replytype, + commandOptions:{ + interactionId:msg.interaction.id, + interactionName:msg.interaction.commandName + }, + user:{ + name:msg.interaction.user.username, + id:msg.interaction.user.id, + color:replycolor, + pfp:msg.interaction.user.displayAvatarURL(), + bot:msg.interaction.user.bot, + system:msg.interaction.user.system, + verifiedBot:msg.interaction.user.flags.has(discord.UserFlags.VerifiedBot) + } + } + }else if (replytype == "reply"){ + + var replycontentRAW = messages.find((msg2) => msg2.id == msg.reference.messageId) + var replycontent = (replycontentRAW && replycontentRAW.content) ? replycontentRAW.content.slice(0,(60-replycontentRAW.author.username.length)) : "deleted this message" + const replycolorRAW = (replycontentRAW) ? msg.guild.members.cache.find((m) => m.id == replycontentRAW.author.id) : false + const replycolor = (replycolorRAW) ? replycolorRAW.displayHexColor.replace("#000000","#ffffff") : "#ffffff" + + var user = (replycontentRAW && replycontentRAW.content) ? { + name:(replycontentRAW) ? replycontentRAW.author.username : "undefined", + id:(replycontentRAW) ? replycontentRAW.author.id : "undefined", + color:replycolor, + pfp:(replycontentRAW) ? replycontentRAW.author.username : "", + bot:(replycontentRAW) ? replycontentRAW.author.bot : false, + system:(replycontentRAW) ? replycontentRAW.author.system : false, + verifiedBot:(replycontentRAW) ? replycontentRAW.author.flags.has(discord.UserFlags.VerifiedBot) : false, + } : { + name:"someone", + id:"undefined", + color:"#ffffff", + pfp:"https://raw.githubusercontent.com/twitter/twemoji/master/assets/72x72/1f5d1.png", + bot:false, + system:false, + verifiedBot:false, + } + + var reply = { + type:replytype, + replyOptions:{ + content:replycontent, + messageId: msg.reference.messageId, + channelId: msg.reference.channelId, + guildId: msg.reference.guildId + }, + user:user + } + }else{var reply = {type:replytype}} + + const authorColor = msg.member ? msg.member.displayHexColor.replace("#000000","#ffffff") : "#ffffff" + messagesArray.push({ + author:{ + name:msg.author.tag, + id:msg.author.id, + color:authorColor, + pfp:msg.author.displayAvatarURL(), + bot:msg.author.bot, + system:msg.author.system, + verifiedBot:msg.author.flags.has(discord.UserFlags.VerifiedBot) + }, + content:mentions(msg.content,guild) || "", + timestamp:msg.createdTimestamp, + embeds:embedArray, + attachments:attachmentArray, + edited: (typeof msg.editedTimestamp == "number"), + type:"normal", + important:important, + reply:reply, + components:componentsArray + }) + }else {invisibleMessages++} + }) + + const dsb = data.style.background + const dsh = data.style.header + const dss = data.style.stats + + /**@type {OTTranscriptCompileInput} */ + const result = { + version,otversion, + language:bot.config.languageFile, + style:{ + background:{ + backgroundData:dsb.backgroundData || "", + backgroundModus:dsb.backgroundModus || "", + enableCustomBackground:dsb.enableCustomBackground || false, + }, + header:{ + backgroundColor:dsh.backgroundColor || "#202225", + decoColor:dsh.decoColor || "#F8BA00", + textColor:dsh.textColor || "#ffffff", + enableCustomHeader:dsh.enableCustomHeader || false + }, + stats:{ + backgroundColor:dss.backgroundColor || "#202225", + keyTextColor:dss.keyTextColor || "#737373", + valueTextColor:dss.valueTextColor || "#ffffff", + hideBackgroundColor:dss.hideBackgroundColor || "#40444a", + hideTextColor:dss.hideTextColor || "#ffffff", + enableCustomStats:dss.enableCustomStats || false + } + }, + bot:{ + name:data.bot.name || "Open Ticket", + id:data.bot.id || 0, + pfp:data.bot.pfp || "dj-dj.be/wp-content/uploads/2022/07/profielfoto-blauw-wit.png?size=128" + }, + ticket:{ + name:channel.name, + id:channel.id, + + guildname:guild.name, + guildid:guild.id, + guildinvite:"", + + creatorname:data.ticket.creatorname, + creatorid:data.ticket.creatorid, + creatorpfp:data.ticket.creatorpfp, + + closedbyname:user.tag, + closedbyid:user.id, + closedbypfp:user.displayAvatarURL(), + + claimedid:"", + claimedname:"", + claimedpfp:"", + + closedtime:data.ticket.closedtime, + openedtime:data.ticket.openedtime, + + roleColors:[], + components:{ + messages:messageAmount, + embeds:embedAmount, + files:fileAmount, + interactions:{ + buttons:0, + dropdowns:0, + total:interactionAmount + }, + reactions:reactionsAmount, + attachments:{ + gifs:0, + images:0, + stickers:0, + invites:0 + } + } + }, + messages:messagesArray, + premium:{ + enabled:false, + premiumToken:"", + + customCredits:{ + enable:false, + replaceText:"Powered By Open Ticket!", + replaceURL:"https://openticket.dj-dj.be", + enableReportBug:true + }, + customHeaderUrl:{ + enabled:false, + url:"https://openticket.dj-dj.be", + text:"Hello!" + }, + customTranscriptUrl:{ + enabled:false, + name:"test-server" + }, + customFavicon:{ + enabled:false, + image:"https://openticket.dj-dj.be" + }, + additionalFlags:[] + } + } + + + return result +} \ No newline at end of file diff --git a/core/transcriptSystem/communication/index.js b/core/transcriptSystem/communication/index.js index 64235d3..43bcf07 100644 --- a/core/transcriptSystem/communication/index.js +++ b/core/transcriptSystem/communication/index.js @@ -6,7 +6,7 @@ const tsconfig = bot.tsconfig const tsembeds = require("../embeds") const tsdb = require("../tsdb") -/**@typedef {{status:"success"|"error", id:String, time:Number, estimated:{lastdump: Number, processtime:Number}, transcriptstatus:{value:2, data:{fetchedmsgs:true, uploaded:true, inqueue:true, processed:false, waiting:false, available:false}}}} OTuploadResponse */ +/**@typedef {{status:"success"|"error", id:String, time:Number, estimated:{lastdump: Number, processtime:Number,waittime:Number}, transcriptstatus:{value:2, data:{fetchedmsgs:true, uploaded:true, inqueue:true, processed:false, waiting:false, available:false}}}} OTuploadResponse */ /** * @param {Object} json @@ -17,12 +17,13 @@ exports.upload = async (json) => { const data = encodeURIComponent(JSON.stringify(json)) try { - const res = await axios.get("https://api.transcripts.dj-dj.be/upload?auth=openticketTRANSCRIPT1234&version=1.0.0&data="+data) + const res = await axios.post("https://transcripts.dj-dj.be/api/upload?auth=openticketTRANSCRIPT1234&version=2",JSON.stringify(json)) + //const res = await axios.get("https://transcripts.dj-dj.be/api/upload?auth=openticketTRANSCRIPT1234&version=2&data="+data) if (res.status != 200) resolve(false) - + resolve(res.data) - }catch{ - console.log("failed transcript upload!") + }catch(err){ + console.log("failed transcript upload!",err.response) resolve(false) } }) diff --git a/core/transcriptSystem/communication/mentions.js b/core/transcriptSystem/communication/mentions.js new file mode 100644 index 0000000..9523ed2 --- /dev/null +++ b/core/transcriptSystem/communication/mentions.js @@ -0,0 +1,63 @@ +const discord = require('discord.js') + +const bot = require("../../../index") +const tsconfig = bot.tsconfig +const tsembeds = require("../embeds") +const tsdb = require("../tsdb") + +/** + * + * @param {String} text + * @param {discord.Guild} guild + */ +exports.replacementions = (text,guild) => { + const userregex = /<@([0-9]+)>(\s)?/g + const usertext = text.replace(userregex,(x) => { + var res = userregex.exec(x) + userregex.lastIndex = 0 + + var member = guild.members.cache.find((m) => m.id == res[1]) + var text = member ? member.user.username.replace(/\s/g," ") : res[1] + return "<@"+text+"> " + }) + + const channelregex = /<#([0-9]+)>(\s)?/g + const channeltext = usertext.replace(channelregex,(x) => { + var res = channelregex.exec(x) + channelregex.lastIndex = 0 + + var channel = guild.channels.cache.find((c) => c.id == res[1]) + var text = channel ? channel.name.replace(/\s/g," ") : res[1] + return "<#"+text+"> " + }) + + const roleregex = /<@&([0-9]+)>(\s)?/g + const roletext = channeltext.replace(roleregex,(x) => { + var res = roleregex.exec(x) + roleregex.lastIndex = 0 + + var role = guild.roles.cache.find((r) => r.id == res[1]) + var text = role ? role.name.replace(/\s/g," ") : res[1] + + var color = role ? ((role.hexColor == "#000000") ? "regular" : role.hexColor) : "regular" + + return "<@&"+text+"::"+color+"> " + }) + + const defaultroleregex = /@(everyone|here)(\s)?/g + const defaultroletext = roletext.replace(defaultroleregex,(x) => { + var res = defaultroleregex.exec(x) + defaultroleregex.lastIndex = 0 + + var text = res[1] + return "<@&"+text+"::regular> " + }) + /**TODO!!!!!!! + * - remove console.log :) + * - set role colors in ENTIRE TRANSCRIPT (users,replies,mentions,...) to #ffffff if #000000 + * because black => default color + * - see compileJsonV2 + */ + + return defaultroletext +} \ No newline at end of file diff --git a/core/transcriptSystem/communication/template.json b/core/transcriptSystem/communication/template.json deleted file mode 100644 index 3c1ab69..0000000 --- a/core/transcriptSystem/communication/template.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "version":"1.0.0", - "otversion":"3.4.0", - "style":{ - "enableCustomBackground":false, - "backgroundModus":"color OR image", - "backgroundData":"#ffffff OR https://www.example.com/image.png", - "titleColor":"#ffffff" - }, - "bot":{ - "name":"DJdj Support Bot", - "id":12345678910, - "pfp":"https://www.example.com/image.png" - }, - "ticket":{ - "name":"support-DJj123dj", - "id":12345678910, - - "guildname":"DJdj Development", - "guildid":12345678910, - - "creatorname":"DJj123dj#1706", - "creatorid":12345678910, - "closedbyname":"DJj123dj#1706", - "closedbyid":12345678910, - - "closedtime":12345678910, - "openedtime":12345678910, - - "messages":1, - "files":1 - }, - "messages":[ - { - "author":{ - "name":"DJj123dj#1706", - "id":12345678910, - "color":"#ffffff", - "pfp":"https://www.example.com/image.png" - }, - "content":"string or FALSE", - "timestamp":12345678910, - "embeds":[ - { - "title":"string or FALSE", - "description":"string or FALSE", - "authorimg":"https://www.example.com/image.png or FALSE", - "authortext":"string or FALSE", - "footerimg":"https://www.example.com/image.png or FALSE", - "footertext":"string or FALSE", - "color":"#ffffff", - "image":"https://www.example.com/image.png or FALSE", - "thumbnail":"https://www.example.com/image.png or FALSE", - "url":"https://www.example.com/image.png or FALSE" - } - ], - "files":[ - { - "name":"image.png", - "type":"PNG", - "size":"1MB", - "url":"https://www.example.com/image.png" - } - ] - } - ] -} \ No newline at end of file diff --git a/core/transcriptSystem/info.json b/core/transcriptSystem/info.json index ea2feef..1c4b27e 100644 --- a/core/transcriptSystem/info.json +++ b/core/transcriptSystem/info.json @@ -1,3 +1,3 @@ { - "version":"1.0.0" + "version":"2" } \ No newline at end of file diff --git a/core/transcriptSystem/manager.js b/core/transcriptSystem/manager.js index 7c447b7..10cc01a 100644 --- a/core/transcriptSystem/manager.js +++ b/core/transcriptSystem/manager.js @@ -14,11 +14,15 @@ const tsdb = require("./tsdb") const checkAvailability = async () => { if (process.argv.some((v) => v == "--tsoffline")) return true const axios = require("axios").default - const res = await axios.get("https://transcripts.dj-dj.be/status.txt") - if (!res || !(res.status == 200) || !res.data) return false + try{ + const res = await axios.get("https://transcripts.dj-dj.be/api/status.json") + if (!res || !(res.status == 200) || !res.data) return false - if ((res.data == "online") || (res.data == "1") || (res.data == "true")) return true - else return false + if (res.data && res.data["v2"] == "online") return true + else return false + }catch{ + return false + } } /** @@ -48,21 +52,42 @@ module.exports = async (messages,guild,channel,user,reason) => { const ticketopener = client.users.cache.find(u => u.id == id) if (tsconfig.sendTranscripts.useHTMLtranscripts){ - const JSONDATA = require("./communication/compileJson").compile(guild,channel,user,messages,{ + const tsb = tsconfig.style.background + const tsh = tsconfig.style.header + const tss = tsconfig.style.stats + const JSONDATA = require("./communication/compileJsonV2").compile(guild,channel,user,messages,{ style:{ - titleColor:tsconfig.style.titleColor, - enableCustomBackground:tsconfig.style.background.enableCustomBackground, - backgroundModus:tsconfig.style.background.backgroundModus, - backgroundData:tsconfig.style.background.backgroundData + background:{ + enableCustomBackground:tsb.enableCustomBackground, + backgroundModus:tsb.backgroundModus, + backgroundData:tsb.backgroundData + }, + header:{ + enableCustomHeader:tsh.enableCustomHeader, + backgroundColor:tsh.backgroundColor, + decoColor:tsh.decoColor, + textColor:tsh.textColor + }, + stats:{ + enableCustomStats:tss.enableCustomStats, + backgroundColor:tss.backgroundColor, + keyTextColor:tss.keyTextColor, + valueTextColor:tss.valueTextColor, + hideBackgroundColor:tss.hideBackgroundColor, + hideTextColor:tss.hideTextColor + } + }, bot:{ name:client.user.username, id:client.user.id, - pfp:client.user.displayAvatarURL() + pfp:client.user.displayAvatarURL(), }, ticket:{ creatorid:ticketopener.id, creatorname:ticketopener.tag, + creatorpfp:ticketopener.displayAvatarURL(), + openedtime:opentime.getTime(), closedtime:new Date().getTime() } @@ -86,16 +111,17 @@ module.exports = async (messages,guild,channel,user,reason) => { if (!TSdata) return false if (TSdata.status == "success"){ - const url = "https://transcripts.dj-dj.be/t/"+TSdata.time+"_"+TSdata.id+".html" + //MAKE THIS COMPATIBLE WITH PREMIUM "customTranscriptUrl" IN FUTURE VERSIONS!! + const url = "https://transcripts.dj-dj.be/v2/"+TSdata.time+"_"+TSdata.id+".html" //calculate estimated time - const lastDumpTime = (new Date(TSdata.estimated.lastdump).getTime()) - const dumpLoopTime = 15000 - const nextDump = new Date(lastDumpTime+dumpLoopTime) - const processtime = TSdata.estimated.processtime+6000 //6sec extra time for overflow + //const lastDumpTime = (new Date(TSdata.estimated.lastdump).getTime()) + //const dumpLoopTime = 15000 + //const nextDump = new Date(lastDumpTime+dumpLoopTime) + //const processtime = TSdata.estimated.processtime+6000 //6sec extra time for overflow - const finaltime = new Date(nextDump.getTime()+processtime) - const duration = finaltime.getTime()-new Date().getTime() + const duration = TSdata.estimated.waittime + const finaltime = new Date(new Date().getTime()+duration) //waiting if (tsconfig.sendTranscripts.enableChannel){ diff --git a/language/slashcmds/slash.json b/language/slashcmds/slash.json index 473e6d4..88186c4 100644 --- a/language/slashcmds/slash.json +++ b/language/slashcmds/slash.json @@ -10,6 +10,7 @@ "es-ES":"spanish", "it":"italian", "ru":"russian", + "tr": "Türkçe", "MISSING":"arabic,portuguese", "NOTAVAILABLE":"arabic,portuguese,czech" @@ -25,7 +26,8 @@ "fr":"Une liste des commandes.", "es-ES":"Una lista de los comandos disponibles.", "it":"Una lista di tutti i comandi disponibili.", - "ru":"Список доступных команд" + "ru":"Список доступных команд", + "tr": "Kullanılabilir komutların listesi." }, "message":{ "en-GB":"Spawn an embed with buttons.", @@ -37,7 +39,8 @@ "fr":"Créer un embed avec des boutons.", "es-ES":"Genera un embed con botones.", "it":"Genera un embed con un pulsante.", - "ru":"Создать embed с кнопками" + "ru":"Создать embed с кнопками", + "tr": "Butonlar ile bir yerleştirme oluşturun." }, "close":{ "en-GB":"Close a ticket.", @@ -49,7 +52,8 @@ "fr":"Fermer un ticket.", "es-ES":"Cierra un ticket.", "it":"Chiudi un ticket.", - "ru":"Закрыть тикет" + "ru":"Закрыть тикет", + "tr": "Bileti kapat." }, "delete":{ "en-GB":"Delete a ticket.", @@ -61,7 +65,8 @@ "fr":"Supprimer un ticket.", "es-ES":"Elimina un ticket.", "it":"Elimina un ticket.", - "ru":"Удалить тикет" + "ru":"Удалить тикет", + "tr": "Bileti sil." }, "reopen":{ "en-GB":"Re-Open a ticket.", @@ -73,7 +78,8 @@ "fr":"Re-ouvrir un ticket.", "es-ES":"Re-abre un ticket.", "it":"Ri-Apri un ticket.", - "ru":"Открыть заново тикет" + "ru":"Открыть заново тикет", + "tr": "Bileti yeniden aç." }, "add":{ "en-GB":"Add another user to a ticket.", @@ -85,7 +91,8 @@ "fr":"Ajouter un utilisateur au ticket.", "es-ES":"Agrega otro usuario al ticket.", "it":"Aggiungi un membro al ticket", - "ru":"Добавить другого пользователя в тикет" + "ru":"Добавить другого пользователя в тикет", + "tr": "Bilete başka bir kullanıcı ekle." }, "remove":{ "en-GB":"Remove a user from a ticket.", @@ -97,7 +104,8 @@ "fr":"Enlever quelqu’un du ticket.", "es-ES":"Elimina otro usuario del ticket.", "it":"Rimuovi un membro dal ticket", - "ru":"Удалить пользователя из тикета" + "ru":"Удалить пользователя из тикета", + "tr": "Kullanıcıyı bir biletten kaldır." }, "newticket":{ "en-GB":"Create a ticket", @@ -109,7 +117,8 @@ "fr":"Créer un ticket", "es-ES":"Crear un ticket.", "it":"Crea un ticket", - "ru":"Создать тикет" + "ru":"Создать тикет", + "tr": "Bilet oluştur" }, "rename":{ "en-GB":"Rename a ticket channel.", @@ -121,7 +130,8 @@ "fr":"Renommer un ticket.", "es-ES":"Renombrar un canal de ticket.", "it":"Rinomina il canale di un ticket.", - "ru":"Переименовать канал тикета" + "ru":"Переименовать канал тикета", + "tr": "Bilet kanalını yeniden adlandır." }, "claim":{ "en-GB":"Claim a ticket.", @@ -133,7 +143,8 @@ "fr":" ", "es-ES":" ", "it":" ", - "ru":"Взять тикет" + "ru":"Взять тикет", + "tr":"Bilet talep et." }, "unclaim":{ "en-GB":"Un-claim a ticket.", @@ -145,7 +156,8 @@ "fr":" ", "es-ES":" ", "it":" ", - "ru":"Снять тикет" + "ru":"Снять тикет", + "tr":"Bileti iptal et." }, "category":{ "en-GB":"Change ticket type.", @@ -157,7 +169,8 @@ "fr":" ", "es-ES":" ", "it":" ", - "ru":"Изменить тип тикета" + "ru":"Изменить тип тикета", + "tr":"Bilet türünü değiştir." } } } \ No newline at end of file diff --git a/language/thai.json b/language/thai.json new file mode 100644 index 0000000..6cecb5a --- /dev/null +++ b/language/thai.json @@ -0,0 +1,98 @@ +{ + "errors":{ + "missingArgsTitle":"อาร์กิวเมนต์ไม่ถูกต้อง!", + "missingArgsDescription":"อาร์กิวเมนต์ไม่ครบ", + "noPermsTitle":"ไม่มีสิทธิ์!", + "noPermsDescription":"คุณต้องมีสิทธิ์ ADMINISTRATOR หรืออยู่ในรายชื่อบทบาทที่อนุญาต!", + "noPermsDelete":"เฉพาะผู้ดูแลระบบเท่านั้นที่สามารถลบตั๋วได้!", + "chooseFromListTitle":"ID ไม่ถูกต้อง", + "chooseFromListDescription":"เลือกหนึ่งใน ID ด้านล่าง:", + "boterror":"ข้อผิดพลาดของบอท!", + "notInTicketTitle":"คุณไม่ได้อยู่ในตั๋ว!", + "notInTicketDescription":"คำสั่งนี้ไม่สามารถทำงานนอกตั๋วได้!", + "ticketDoesntExist":"ตั๋วนี้ไม่มีอยู่แล้ว!", + "roleDoesntExist":"บทบาทนี้ไม่มีอยู่แล้ว!", + "anotherOption":"ตัวเลือกนี้ไม่ใช่ตั๋วแต่เป็นประเภทอื่น!", + "maxAmountTitle":"จำนวนสูงสุดแล้ว!", + "maxAmountDescription":"คุณได้สร้างตั๋วครบจำนวนที่เราให้สร้างไว้แล้ว\nดังนั้นคุณไม่สามารถสร้างตั๋วใหม่ได้!", + "somethingWentWrong":"เกิดข้อผิดพลาดบางอย่าง!\nโปรดลองอีกครั้งในครั้งถัดไป!" + }, + "commands":{ + "userAddedTitle":"เพิ่ม {0} เข้าสู่ตั๋วนี้แล้ว!", + "userRemovedTitle":"นำ {0} ออกจากตั๋วนี้แล้ว!", + "renameTitle":"เปลี่ยนชื่อเป็น {0}!", + "closeTitle":"ปิดตั๋วนี้!", + "deleteTitle":"กำลังลบตั๋วนี้...", + "reopenTitle":"เปิดตั๋วนี้ใหม่!", + + "claimTitle":"ตั๋วนี้ถูกเรียกเก็บโดย {0}", + "unclaimTitle":"ไม่มีการเรียกเก็บตั๋วนี้อีกต่อไป!", + "changeTitle":"เปลี่ยนประเภทตั๋วเป็น {0}!", + + "statsTitle":"นี่คือสถิติสำหรับ {0}!", + "autocloseTitle":"ตั๋วนี้จะถูกปิดอัตโนมัติหลังจาก {0}!", + "autocloseRejectTitle":"ตั๋วนี้จะไม่ถูกปิดอัตโนมัติอีกต่อไป!", + "autocloseWarn":"สิ่งนี้มีผลต่อตั๋วที่ไม่มีการเคลื่อนไหว!", + + "goToTicket":"ไปยังตั๋ว", + "ticketWarning":"Embed อยู่ในข้อความข้างล่าง", + "maxTicketWarning":"**คำเตือน:** _คุณสามารถสร้างตั๋วได้สูงสุด {0} ตั๋วต่อครั้ง!_" + }, + "helpMenu":{ + "title":"คำสั่งที่มีอยู่:", + "header1":"**ไปที่ {0} เพื่อสร้างตั๋ว!**\n\n", + "header2":"**ใช้คำสั่ง `/new` หรือ `/ticket` เพื่อสร้างตั๋ว!**\n\n", + + "msgCmd":"แสดง Embed พร้อมปุ่ม (สำหรับแอดมินเท่านั้น)", + "renameCmd":"เปลี่ยนชื่อตั๋ว (ห้ามมีช่องว่าง)", + "closeCmd":"ปิดตั๋ว", + "deleteCmd":"ลบตั๋ว", + "addCmd":"เพิ่มผู้ใช้เข้าสู่ตั๋ว", + "removeCmd":"นำผู้ใช้ออกจากตั๋ว", + "reopenCmd":"เปิดตั๋วใหม่หลังจากถูกปิด", + "changeCmd":"เปลี่ยนประเภทตั๋ว", + "claimCmd":"เรียกเก็บตั๋ว", + "unclaimCmd":"ยกเลิกการเรียกเก็บตั๋ว", + "statsCmd":"ดูสถิติของตั๋ว", + "autocloseCmd":"ตั้งเวลาปิดตั๋วโดยอัตโนมัติ" + }, + "buttons":{ + "close":"ปิดตั๋ว", + "delete":"ลบตั๋ว", + "reopen":"เปิดตั๋วใหม่", + "closeWithReason":"ปิดตั๋วพร้อมเหตุผล" + }, + "messages":{ + "closedDescription":"ตอนนี้เฉพาะผู้ดูแลเท่านั้นที่สามารถพูดได้ในตั๋วนี้!\n\n*คลิกที่ปุ่มด้านล่างเพื่อลบหรือเปิดตั๋วใหม่!*", + "createdTitle":"สร้างตั๋วแล้ว!", + "createdDescription":"ตั๋วของคุณถูกสร้างเรียบร้อยแล้ว คุณจะได้รับการแจ้งเตือนด้วยการพิมพ์ข้อความด้วย @ ตามตั๋วของคุณ!", + + "newTicketDmTitle":"ตั๋วใหม่!", + "closedTicketDmTitle":"ตั๋วถูกปิด!", + "deletedTicketDmTitle":"ตั๋วถูกลบ!", + "closedTicketDmDescription":"ตั๋วของคุณถูกปิด!", + "deletedTicketDmDescription":"ตั๋วของคุณถูกลบ!", + "reopenTicketDmTitle":"ตั๋วถูกเปิดใหม่!", + "reopenTicketDmDescription":"ตั๋วของคุณถูกเปิดใหม่!", + + "chooseCategory":"เลือกหมวดหมู่:", + "gettingdeleted":"กำลังลบตั๋ว...", + + "none":"ไม่มี", + "reason":"เหตุผล", + "createdat":"สร้างเมื่อ", + "openedby":"เปิดโดย", + "deletedby":"ลบโดย", + "closedby":"ปิดโดย", + + "modalreason":"เหตุผลที่ต้องการปิดตั๋ว?", + "chooseATicket": "เลือกตั๋ว" + }, + "transcripts":{ + "title":"บันทึกข้อความ", + "processed":"กำลังประมวลผลบันทึกข้อความ", + "wait":"โปรดรอสักครู่!", + "estimated":"เวลาโดยประมาณ", + "available":"บันทึกข้อความพร้อมใช้งานที่นี่" + } +} \ No newline at end of file diff --git a/transcriptconfig.json b/transcriptconfig.json index a5c003c..d5db7ff 100644 --- a/transcriptconfig.json +++ b/transcriptconfig.json @@ -7,12 +7,26 @@ "useHTMLtranscripts":true }, "style":{ - "titleColor":"#F8BA00", "background":{ "enableCustomBackground":false, - "backgroundModus":"color OR image", - "backgroundData":"#abc123 OR https://www.example.com/image.png" + "backgroundModus":"image OR color", + "backgroundData":"image url OR hex color (#ffffff)" + }, + "header":{ + "enableCustomHeader":false, + "backgroundColor":"#202225", + "decoColor":"#F8BA00", + "textColor":"#ffffff" + + }, + "stats":{ + "enableCustomStats":false, + "backgroundColor":"#202225", + "keyTextColor":"#737373", + "valueTextColor":"#ffffff", + "hideBackgroundColor":"#40444a", + "hideTextColor":"#ffffff" } } } \ No newline at end of file