This commit is contained in:
DJj123dj
2023-08-11 11:22:25 +02:00
parent bf7a003799
commit 589bbe5cd5
29 changed files with 145 additions and 38 deletions
+16 -10
View File
@@ -3,6 +3,9 @@ const bot = require("../../index")
const log = bot.errorLog.log
module.exports = () => {
const args = process.argv
const debugMode = args.includes("--debug")
const files = fs.readdirSync("./plugins")
const api = require("./api.json")
var totalcount = 0
@@ -11,27 +14,30 @@ module.exports = () => {
files.forEach((file) => {
if (file.endsWith(".plugin.js")){
try {
require("../../plugins/"+file)()
require("../../plugins/" + file)()
successcount++
totalcount++
}catch(err){
/**@type {Error} */
const theError = err
if (api.enableAPIdebug){
try {
const data = fs.readFileSync("./apiDebug.txt")
const newData = data ? data.toString() : ""
fs.writeFileSync("./apiDebug.txt",newData+"ERROR: "+theError.name+": "+theError.message+"\n"+theError.stack+"\n\n")
}catch{
fs.writeFileSync("./apiDebug.txt","ERROR: "+theError.name+": "+theError.message+"\n"+theError.stack+"\n\n")
}
if (api.enableAPIdebug || debugMode) {
console.error(theError)
}
try {
const data = fs.readFileSync("./openticketdebug.txt")
const newData = data ? data.toString() : ""
fs.writeFileSync("./openticketdebug.txt", newData + "\nPLUGIN "+file+" ERROR: " + theError.name + ": " + theError.message + "\n" + theError.stack + "\n\n")
} catch {
fs.writeFileSync("./openticketdebug.txt", "\nPLUGIN "+file+" ERROR: " + theError.name + ": " + theError.message + "\n" + theError.stack + "\n\n")
}
failcount++
totalcount++
}
}
})
require("../startscreen").headerDataPlugins({total:totalcount,success:successcount,error:failcount})
require("../startscreen").headerDataPlugins({ total: totalcount, success: successcount, error: failcount })
}