From 65f82171d3c1e27f182b2cd1a118eb0678bb3fdf Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Fri, 24 Feb 2023 21:48:59 +0100 Subject: [PATCH] v3.2.2 push 4 --- core/api/pluginlauncher.js | 2 +- core/languageManager.js | 4 +- core/logo.txt | 7 +++ core/slashSystem/autoSlashUpdate.js | 1 - core/startscreen.js | 75 +++++++++++++++++++++++++++++ index.js | 75 +++-------------------------- 6 files changed, 93 insertions(+), 71 deletions(-) create mode 100644 core/logo.txt create mode 100644 core/startscreen.js diff --git a/core/api/pluginlauncher.js b/core/api/pluginlauncher.js index 0f70e93..1d8edf3 100644 --- a/core/api/pluginlauncher.js +++ b/core/api/pluginlauncher.js @@ -33,5 +33,5 @@ module.exports = () => { } }) - log("info","loaded plugins",[{key:"success",value:successcount},{key:"error",value:failcount},{key:"total",value:totalcount}]) + require("../startscreen").headerDataPlugins({total:totalcount,success:successcount,error:failcount}) } \ No newline at end of file diff --git a/core/languageManager.js b/core/languageManager.js index a9909b1..198533f 100644 --- a/core/languageManager.js +++ b/core/languageManager.js @@ -13,13 +13,13 @@ if (lfexists) localLanguage = require("../language/"+config.languagefile+".json" const errorLog = async () => { const chalk = await (await import("chalk")).default - console.log(chalk.red("Something went wrong when loading the language!")+"\nCheck the config file or create a ticket in our server!") + require("./startscreen").headerDataLanguage("Something went wrong when loading the language!",true) } const successLog = async (language) => { const chalk = await (await import("chalk")).default - console.log(chalk.green("loaded language "+language+"...")) + require("./startscreen").headerDataLanguage("sucessfully loaded language "+language,false) } if (!localLanguage){ diff --git a/core/logo.txt b/core/logo.txt new file mode 100644 index 0000000..2a9c369 --- /dev/null +++ b/core/logo.txt @@ -0,0 +1,7 @@ + + ██████╗ ██████╗ ███████╗███╗ ██╗ ████████╗██╗ ██████╗██╗ ██╗███████╗████████╗ +██╔═══██╗██╔══██╗██╔════╝████╗ ██║ ╚══██╔══╝██║██╔════╝██║ ██╔╝██╔════╝╚══██╔══╝ +██║ ██║██████╔╝█████╗ ██╔██╗ ██║ ██║ ██║██║ █████╔╝ █████╗ ██║ +██║ ██║██╔═══╝ ██╔══╝ ██║╚██╗██║ ██║ ██║██║ ██╔═██╗ ██╔══╝ ██║ +╚██████╔╝██║ ███████╗██║ ╚████║ ██║ ██║╚██████╗██║ ██╗███████╗ ██║ + ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝ \ No newline at end of file diff --git a/core/slashSystem/autoSlashUpdate.js b/core/slashSystem/autoSlashUpdate.js index 3ef73c6..ba610aa 100644 --- a/core/slashSystem/autoSlashUpdate.js +++ b/core/slashSystem/autoSlashUpdate.js @@ -8,7 +8,6 @@ const act = discord.ApplicationCommandType const acot = discord.ApplicationCommandOptionType module.exports = async () => { - bot.errorLog.log("info","auto-updating slash commands...") const sid = config.server_id const ids = configParser.getTicketValuesArray("id") diff --git a/core/startscreen.js b/core/startscreen.js new file mode 100644 index 0000000..7c8159b --- /dev/null +++ b/core/startscreen.js @@ -0,0 +1,75 @@ +const discord = require('discord.js') +const bot = require('../index') +const client = bot.client +const config = bot.config +const l = bot.language +const log = bot.errorLog.log + +const logo = require("fs").readFileSync("./core/logo.txt").toString() + +/**@param {import('chalk').ChalkInstance} chalk */ +const showFlags = async (chalk) => { + var isFlag = false + if (process.argv.some((v) => v == "--devconfig")) console.log(chalk.blue("[FLAGS] => used dev config instead of normal config")); isFlag = true + if (process.argv.some((v) => v == "--nochecker")) console.log(chalk.blue("[FLAGS] => disabled checker.js")); isFlag = true + if (process.argv.some((v) => v == "--tsoffline")) console.log(chalk.blue("[FLAGS] => offline check for html transcripts disabled!")); isFlag = true + if (process.argv.some((v) => v == "--debug")) console.log(chalk.blue("[FLAGS] => enabled DEBUG mode")); isFlag = true + + if (!isFlag) console.log(chalk.blue("no flags!")) +} + +exports.run = async () => { + const chalk = await (await import("chalk")).default + console.log(chalk.hex("f8ba00")(logo)) + const version = require("../package.json").version + var headertext = "v"+version+" - Support: https://discord.dj-dj.be - Language: "+config.languagefile + const spaceamount = (84-headertext.length)/2 + var i = 0 + while (i < spaceamount){ + headertext = " "+headertext + i++ + } + console.log(chalk.bold(headertext+"\n")) + console.log(chalk.bold(chalk.underline("FLAGS:"))) + showFlags(chalk) +} + +/** + * @param {import('chalk').ChalkInstance} chalk + * @param {{type:String,text:String,enabled:Boolean}} status + * @param {Boolean} updatingslash + * @param {Boolean} slashmode + * +*/ +exports.headerDataReady = (chalk,status,updatingslash,slashmode) => { + console.log("\n"+chalk.bold(chalk.underline("STARTUP INFO:"))) + if (status.enabled) console.log(chalk.hex("f8ba00")("status: ")+chalk.bold(status.type.toLowerCase())+" "+status.text) + if (slashmode){ + console.log("\n\n"+chalk.red(chalk.underline("STARTING IN SLASH CMD CONFIGURATION MODE!"))) + return + } + console.log(chalk.hex("f8ba00")("updating slash cmds: ")+chalk.bold(slashmode)) +} + +var languageMSG = "" +var languageErr = false +/** + * @param {String} message + * @param {Boolean} err +*/ +exports.headerDataLanguage = async (message,err) => { + languageMSG = message + languageErr = err +} + +/** + * @param {{total:Number,error:Number,success:Number}} plugins +*/ +exports.headerDataPlugins = async (plugins) => { + const chalk = await (await import("chalk")).default + const lmsg = languageErr ? chalk.red(languageMSG) : languageMSG + console.log(chalk.hex("f8ba00")("language: ")+lmsg) + console.log(chalk.hex("f8ba00")("plugins loaded: ")+chalk.bold(plugins.total+" total ")+"("+plugins.success+"✅ "+plugins.error+"❌)") + + console.log("\n"+chalk.bold(chalk.underline("LOGS:"))) +} \ No newline at end of file diff --git a/index.js b/index.js index 31e4e22..5701f37 100644 --- a/index.js +++ b/index.js @@ -72,10 +72,6 @@ var tempconfig = require("./config.json") var isDevConfig = false if (process.argv.some((v) => v == "--devconfig")){ - async function logFLAGS(){ - const chalk = await (await import("chalk")).default - console.log(chalk.blue("[FLAGS] => used dev config instead of normal config")) - }; logFLAGS() isDevConfig = true try{ tempconfig = require("./devconfig.json") @@ -83,24 +79,6 @@ if (process.argv.some((v) => v == "--devconfig")){ }else{ tempconfig = require("./config.json") } -if (process.argv.some((v) => v == "--nochecker")){ - async function logFLAGS(){ - const chalk = await (await import("chalk")).default - console.log(chalk.blue("[FLAGS] => disabled checker.js")) - }; logFLAGS() -} -if (process.argv.some((v) => v == "--tsoffline")){ - async function logFLAGS(){ - const chalk = await (await import("chalk")).default - console.log(chalk.blue("[FLAGS] => offline check for html transcripts disabled!")) - }; logFLAGS() -} -if (process.argv.some((v) => v == "--debug")){ - async function logFLAGS(){ - const chalk = await (await import("chalk")).default - console.log(chalk.blue("[FLAGS] => enabled DEBUG mode")) - }; logFLAGS() -} if (process.argv.some((v) => v == "--debug")) console.log("[TEMP_DEBUG]","loaded flags") exports.developerConfig = isDevConfig @@ -151,74 +129,37 @@ client.on('ready',async () => { } client.user.setActivity(text,{type:getTypeEnum(type)}) statusSet = true - log("system","loaded status",[{key:"type",value:type},{key:"text",value:text}]) } this.errorLog.log("debug","bot status loaded") const chalk = await (await import("chalk")).default - if (!process.argv[2]){ - console.log(chalk.red("WELCOME TO OPEN TICKET!")) + require("./core/startscreen").run() + if (!process.argv[2] || (process.argv[2] && !process.argv[2].startsWith("slash"))){ this.errorLog.log("debug","loaded console interface") - log("info","open ticket ready",[{key:"version",value:require("./package.json").version},{key:"language",value:config.languagefile}]) + require("./core/utils/liveStatus")() - console.log(chalk.blue("\n\nlogs:")+"\n============") if (config.status.enabled){ setStatus(config.status.type,config.status.text) } + var updatingSlash = false if (fs.existsSync("./storage/slashcmdEnabled.txt")){ /**@type {"true"|"false"} */ const data = fs.readFileSync("./storage/slashcmdEnabled.txt").toString() - if (data === "true"){require("./core/slashSystem/autoSlashUpdate")()} + if (data === "true"){require("./core/slashSystem/autoSlashUpdate")(); updatingSlash = true} }else{fs.writeFileSync("./storage/slashcmdEnabled.txt","false")} - log("system","bot logged in!") - - try { - await client.guilds.cache.find((g) => g.id == config.server_id).members.fetch() - }catch{ - this.errorLog.log("info","tried to cache user information, failed!") - } - return - } - - if (process.argv[2] == "d"){ - if (config.status.enabled){ - setStatus(config.status.type,config.status.text) - } - } - - if (!process.argv[2].startsWith("slash")){ - console.log(chalk.red("WELCOME TO OPEN TICKET!")) - this.errorLog.log("debug","loaded console interface") - log("info","open ticket ready",[{key:"version",value:require("./package.json").version},{key:"language",value:config.languagefile}]) - require("./core/utils/liveStatus")() - - console.log(chalk.blue("\n\nlogs:")+"\n============") - if (config.status.enabled){ - setStatus(config.status.type,config.status.text) - } - if (fs.existsSync("./storage/slashcmdEnabled.txt")){ - /**@type {"true"|"false"} */ - const data = fs.readFileSync("./storage/slashcmdEnabled.txt").toString() - if (data === "true"){require("./core/slashSystem/autoSlashUpdate")()} - }else{fs.writeFileSync("./storage/slashcmdEnabled.txt","false")} - - log("system","bot logged in!") - try { await client.guilds.cache.find((g) => g.id == config.server_id).members.fetch() }catch{ this.errorLog.log("info","tried to cache user information, failed!") } + require("./core/startscreen").headerDataReady(chalk,config.status,updatingSlash,false) }else{ - console.log(chalk.red("STARTING IN ")+chalk.blue("SLASH MODE")+chalk.red("...")) + require("./core/startscreen").headerDataReady(chalk,config.status,updatingSlash,true) this.errorLog.log("debug","slashmode activated") - console.log("logs:\n================") - console.log("client logged in...") - console.log("loading files...") if (process.argv[3] == "enable"){ console.log(chalk.green("switching to slashEnable.js")) require("./core/slashSystem/slashEnable")() @@ -226,7 +167,7 @@ client.on('ready',async () => { console.log(chalk.green("switching to slashDisable.js")) require("./core/slashSystem/slashDisable")() }else{ - console.log(chalk.red("[SLASH CMD MANAGER]: unknown slash mode!")) + console.log(chalk.bgRed("[SLASH CMD MANAGER]: unknown slash command action!")) process.exit(1) } }