v3.5.0 push 3

This commit is contained in:
DJj123dj
2023-12-13 12:27:01 +01:00
parent 3447a37603
commit d51511fdb5
9 changed files with 105 additions and 24 deletions
+1
View File
@@ -13,6 +13,7 @@ storage/dynamicDB/
storage/slashcmdEnabled.txt storage/slashcmdEnabled.txt
storage/database.json storage/database.json
storage/tsdatabase.json storage/tsdatabase.json
storage/stats.json
storage/.DS_Store storage/.DS_Store
.vscode/ .vscode/
livestatus.json livestatus.json
+68 -4
View File
@@ -5,11 +5,11 @@ const log = bot.errorLog.log
const l = bot.language const l = bot.language
/**@typedef {"TICKETS_CREATED"|"TICKETS_CLOSED"|"TICKETS_DELETED"|"TICKETS_REOPENED"|"TICKETS_AUTOCLOSED"|"TRANSCRIPTS_CREATED"|"TIME_SINCE_UPDATE"} OTGlobalStatsType */ /**@typedef {"TICKETS_CREATED"|"TICKETS_CLOSED"|"TICKETS_DELETED"|"TICKETS_REOPENED"|"TICKETS_AUTOCLOSED"|"TRANSCRIPTS_CREATED"|"TIME_SINCE_UPDATE"} OTGlobalStatsType */
/**@typedef {"TICKET_AGE"} OTTicketStatsType */ /**@typedef {"TICKET_AGE"|"CREATED_BY"} OTTicketStatsType */
/**@typedef {"TICKETS_CREATED"} OTUserStatsType */ /**@typedef {"TICKETS_CREATED"|"TICKETS_CLOSED"|"TICKETS_DELETED"|"TICKETS_REOPENED"} OTUserStatsType */
/** /**
* @callback OTStatsCallback * @callback OTStatsCallback
* @param {Boolean|Number|String} current * @param {Boolean|Number|String|undefined} current
* @returns {Boolean|Number|String|undefined} * @returns {Boolean|Number|String|undefined}
*/ */
@@ -63,9 +63,73 @@ const removeStats = (scope,type,id) => {
bot.statsStorage.delete(newScope,type) bot.statsStorage.delete(newScope,type)
} }
/**
*
* @param {"global"|"ticket"|"user"} scope
* @param {OTGlobalStatsType|OTTicketStatsType|OTUserStatsType} type
* @param {String} [id]
*/
const existStats = (scope,type,id) => {
const newScope = (scope == "global") ? scope : scope+"_"+id
return (typeof bot.statsStorage.get(newScope,type) == "undefined") ? false : true
}
/**
*
* @param {"global"|"ticket"|"user"} scope
* @param {OTGlobalStatsType|OTTicketStatsType|OTUserStatsType} type
* @param {String} [id]
*/
const getStats = (scope,type,id) => {
const newScope = (scope == "global") ? scope : scope+"_"+id
return bot.statsStorage.get(newScope,type)
}
const startupStatsManager = () => {
if (!existStats("global","TIME_SINCE_UPDATE")){
updateGlobalStats("TIME_SINCE_UPDATE",(current) => {
return new Date().getTime()
})
}
if (!existStats("global","TICKETS_CREATED")){
updateGlobalStats("TICKETS_CREATED",(current) => {
return 0
})
}
if (!existStats("global","TICKETS_CLOSED")){
updateGlobalStats("TICKETS_CLOSED",(current) => {
return 0
})
}
if (!existStats("global","TICKETS_DELETED")){
updateGlobalStats("TICKETS_DELETED",(current) => {
return 0
})
}
if (!existStats("global","TICKETS_AUTOCLOSED")){
updateGlobalStats("TICKETS_AUTOCLOSED",(current) => {
return 0
})
}
if (!existStats("global","TICKETS_REOPENED")){
updateGlobalStats("TICKETS_REOPENED",(current) => {
return 0
})
}if (!existStats("global","TRANSCRIPTS_CREATED")){
updateGlobalStats("TRANSCRIPTS_CREATED",(current) => {
return 0
})
}
}
module.exports = { module.exports = {
updateGlobalStats, updateGlobalStats,
updateTicketStats, updateTicketStats,
updateUserStats, updateUserStats,
removeStats
removeStats,
existStats,
getStats,
startupStatsManager
} }
@@ -10,7 +10,7 @@ const version = require("../info.json").version
const mentions = require("./mentions").replacementions 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 {{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}, favicon:{enableCustomFavicon:Boolean, imageUrl:String}} OTTranscriptStyle} */
/**@typedef {{name:String, id:String, pfp:String}} OTTranscriptBot */ /**@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 {{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 {{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 */
@@ -288,6 +288,7 @@ exports.compile = (guild,channel,user,messagesInv,data) => {
const dsb = data.style.background const dsb = data.style.background
const dsh = data.style.header const dsh = data.style.header
const dss = data.style.stats const dss = data.style.stats
const dsf = data.style.favicon
/**@type {OTTranscriptCompileInput} */ /**@type {OTTranscriptCompileInput} */
const result = { const result = {
@@ -382,8 +383,8 @@ exports.compile = (guild,channel,user,messagesInv,data) => {
name:"test-server" name:"test-server"
}, },
customFavicon:{ customFavicon:{
enabled:false, enabled:dsf.enableCustomFavicon,
image:"https://openticket.dj-dj.be" image:(dsf.imageUrl) ? dsf.imageUrl : "https://openticket.dj-dj.be"
}, },
additionalFlags:[] additionalFlags:[]
} }
+1 -1
View File
@@ -17,7 +17,7 @@ exports.upload = async (json) => {
const data = encodeURIComponent(JSON.stringify(json)) const data = encodeURIComponent(JSON.stringify(json))
try { try {
const res = await axios.post("https://transcripts.dj-dj.be/api/upload?auth=openticketTRANSCRIPT1234&version=2",JSON.stringify(json)) const res = await axios.post("https://apis.dj-dj.be/transcripts/upload?auth=openticketTRANSCRIPT1234&version=2",JSON.stringify(json))
if (res.status != 200) resolve(false) if (res.status != 200) resolve(false)
resolve(res.data) resolve(res.data)
+5
View File
@@ -55,6 +55,7 @@ module.exports = async (messages,guild,channel,user,reason) => {
const tsb = tsconfig.style.background const tsb = tsconfig.style.background
const tsh = tsconfig.style.header const tsh = tsconfig.style.header
const tss = tsconfig.style.stats const tss = tsconfig.style.stats
const tsf = tsconfig.style.favicon
const JSONDATA = require("./communication/compileJsonV2").compile(guild,channel,user,messages,{ const JSONDATA = require("./communication/compileJsonV2").compile(guild,channel,user,messages,{
style:{ style:{
background:{ background:{
@@ -75,6 +76,10 @@ module.exports = async (messages,guild,channel,user,reason) => {
valueTextColor:tss.valueTextColor, valueTextColor:tss.valueTextColor,
hideBackgroundColor:tss.hideBackgroundColor, hideBackgroundColor:tss.hideBackgroundColor,
hideTextColor:tss.hideTextColor hideTextColor:tss.hideTextColor
},
favicon:{
enableCustomFavicon:tsf.enableCustomFavicon,
imageUrl:tsf.imageUrl
} }
}, },
+1 -1
View File
@@ -46,7 +46,7 @@ const getLivestatus = (local) => {
} }
}else{ }else{
try { try {
axios.get("https://livestatus.dj-dj.be/openticket.json").then((res) => { axios.get("https://apis.dj-dj.be/livestatus/announcements/openticket.json").then((res) => {
const livestatus = res.data const livestatus = res.data
if (!Array.isArray(livestatus)) return resolve(false) if (!Array.isArray(livestatus)) return resolve(false)
if (!livestatus) return resolve(false) if (!livestatus) return resolve(false)
+20 -14
View File
@@ -17,13 +17,10 @@
SUGGESTING NEW FEATURES: SUGGESTING NEW FEATURES:
===================== =====================
Open Ticket is a community project. This means that Open Ticket is an open-source community project!
almost all feature ideas come from our community. Because of this, almost 80% of all features in OT were ideas from our community!
Are you missing something you want in open ticket? Feel free to add new ideas in our discord server
Then join our Discord server and we will add it (if possible) or via github issues! Translations are always welcome!
Did you know that 80% of all features in OT were ideas from our community?
INFORMATION: INFORMATION:
@@ -32,7 +29,7 @@
discord: https://discord.dj-dj.be discord: https://discord.dj-dj.be
website: https://www.dj-dj.be website: https://www.dj-dj.be
github: https://openticket.dj-dj.be github: https://github.openticket.dj-dj.be
support e-mail: support@dj-dj.be support e-mail: support@dj-dj.be
Config files: Config files:
@@ -60,6 +57,7 @@ exports.client = client
client.setMaxListeners(50) client.setMaxListeners(50)
if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","created client") if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","created client")
//LOAD CONFIG
var tempconfig = require("./config.json") var tempconfig = require("./config.json")
/**@type {Boolean} */ /**@type {Boolean} */
var isDevConfig = false var isDevConfig = false
@@ -75,15 +73,16 @@ if (process.argv.some((v) => v == "--devconfig")){
if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","loaded flags") if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","loaded flags")
exports.developerConfig = isDevConfig exports.developerConfig = isDevConfig
const config = tempconfig const config = tempconfig
exports.config = config exports.config = config
const tsconfig = isDevConfig ? require("./devtsconfig.json") : require("./transcriptconfig.json") const tsconfig = isDevConfig ? require("./devtsconfig.json") : require("./transcriptconfig.json")
exports.tsconfig = tsconfig exports.tsconfig = tsconfig
//LOAD LANGUAGE
const language = require("./core/languageManager").language const language = require("./core/languageManager").language
exports.language = language exports.language = language
//LOAD FLAGS
if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","loaded language") if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","loaded language")
if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","loaded config") if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","loaded config")
@@ -98,11 +97,10 @@ if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","LOADED
if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","switching to new logs") if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","switching to new logs")
this.errorLog.log("debug","loaded new logs") this.errorLog.log("debug","loaded new logs")
//LOAD SYSTEM LIBRARYS
exports.actionRecorder = require("./core/utils/liveStatus").actionRecorder exports.actionRecorder = require("./core/utils/liveStatus").actionRecorder
exports.hiddenData = require("./core/utils/hiddendata") exports.hiddenData = require("./core/utils/hiddendata")
this.errorLog.log("debug","loaded hiddendataTM") this.errorLog.log("debug","loaded hiddendataTM")
exports.embeds = { exports.embeds = {
commands:require("./core/interactionHandlers/embeds/commands") commands:require("./core/interactionHandlers/embeds/commands")
} }
@@ -113,6 +111,9 @@ exports.buttons = {
} }
this.errorLog.log("debug","loaded buttons & embeds") this.errorLog.log("debug","loaded buttons & embeds")
require("./core/statsManager").startupStatsManager()
//START CLIENT LOGIN PROCESS
client.on('ready',async () => { client.on('ready',async () => {
this.errorLog.log("debug","client logged in") this.errorLog.log("debug","client logged in")
this.actionRecorder.push({ this.actionRecorder.push({
@@ -158,7 +159,6 @@ client.on('ready',async () => {
this.errorLog.log("debug","loaded console interface") this.errorLog.log("debug","loaded console interface")
if (config.status.enabled){ if (config.status.enabled){
console.log("TEST STATUS (delete me)")
setStatus(config.status.type,config.status.text) setStatus(config.status.type,config.status.text)
} }
@@ -232,7 +232,7 @@ client.on('ready',async () => {
} }
} }
//load plugins //LOAD PLUGINS (after client login)
this.actionRecorder.push({ this.actionRecorder.push({
category:"ot.managers.plugins", category:"ot.managers.plugins",
file:"./core/api/pluginlauncher.js", file:"./core/api/pluginlauncher.js",
@@ -248,6 +248,8 @@ client.on('ready',async () => {
}) })
this.errorLog.log("debug","loading plugins") this.errorLog.log("debug","loading plugins")
}) })
//LOAD CHECKER.JS
if (!require("./core/api/api.json").disable.checkerjs.all){ if (!require("./core/api/api.json").disable.checkerjs.all){
this.actionRecorder.push({ this.actionRecorder.push({
category:"ot.managers.main", category:"ot.managers.main",
@@ -266,6 +268,7 @@ if (!require("./core/api/api.json").disable.checkerjs.all){
}) })
} }
//LOAD COMMANDS & CORE
if (process.argv[2] && process.argv[2].startsWith("slash")){ if (process.argv[2] && process.argv[2].startsWith("slash")){
//do nothing //do nothing
}else{ }else{
@@ -320,6 +323,7 @@ if (process.argv[2] && process.argv[2].startsWith("slash")){
}) })
} }
//LOAD API
this.actionRecorder.push({ this.actionRecorder.push({
category:"ot.managers.loader", category:"ot.managers.loader",
file:"./index.js", file:"./index.js",
@@ -337,6 +341,7 @@ this.actionRecorder.push({
type:"api.success" type:"api.success"
}) })
//ERROR SYSTEM
this.actionRecorder.push({ this.actionRecorder.push({
category:"ot.managers.loader", category:"ot.managers.loader",
file:"./index.js", file:"./index.js",
@@ -388,6 +393,7 @@ this.actionRecorder.push({
type:"debugsystem.success" type:"debugsystem.success"
}) })
//LOGIN SYSTEM
const token = config.token.fromENV ? process.env.TOKEN : config.token.value const token = config.token.fromENV ? process.env.TOKEN : config.token.value
client.login(token) client.login(token)
this.errorLog.log("debug","login with token") this.errorLog.log("debug","login with token")
+1 -1
View File
@@ -5,7 +5,7 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
"test": "node index.js --devconfig", "test": "node index.js --devconfig --noerrorupload",
"slashEnable": "node index.js slash enable", "slashEnable": "node index.js slash enable",
"slashDisable": "node index.js slash disable", "slashDisable": "node index.js slash disable",
"cleardata": "node ./core/dynamicdatabase/cleardata.js" "cleardata": "node ./core/dynamicdatabase/cleardata.js"
+4
View File
@@ -27,6 +27,10 @@
"valueTextColor":"#ffffff", "valueTextColor":"#ffffff",
"hideBackgroundColor":"#40444a", "hideBackgroundColor":"#40444a",
"hideTextColor":"#ffffff" "hideTextColor":"#ffffff"
},
"favicon":{
"enableCustomFavicon":false,
"imageUrl":"https://transcripts.dj-dj.be/favicon.png"
} }
} }
} }