From 144deca5e84719ad96fa5f391038e5d8cd643f63 Mon Sep 17 00:00:00 2001 From: hirzidevs Date: Fri, 13 Sep 2024 14:16:03 +0700 Subject: [PATCH] feat: add new executable for changing configuration --- config.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ config.yml | 6 +++--- 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 config.js diff --git a/config.js b/config.js new file mode 100644 index 0000000..1ffbb5a --- /dev/null +++ b/config.js @@ -0,0 +1,46 @@ +const fs = require("node:fs"); +const cliColor = require("cli-color"); +const package = require("./package.json"); +const readline = require('readline').createInterface({ + input: process.stdin, + output: process.stdout +}); + +console.log( + ` _${cliColor.blueBright.bold(`${cliColor.underline("Ptero")}dact${cliColor.underline("yl & P")}eli${cliColor.underline("can")}`)}___ ______ ______ \n` + + ` /\\ ___\\ /\\__ _\\ /\\ __ \\ /\\__ _\\ /\\ ___\\ \n` + + ` \\ \\___ \\ \\/_ \\ \\/ \\ \\ \\_\\ \\ \\/_/\\ \\/ \\ \\___ \\ \n` + + ` \\/\\_____\\ \\ \\_\\ \\ \\_\\ \\_\\ \\ \\_\\ \\/\\_____\\ \n` + + ` \\/_____/ \\/_/ \\/_/\\/_/ \\/_/ \\/_____/${cliColor.yellowBright.bold(`${package.version}-dev`)}` +); + +console.log( + ` \nCopyright © 2022 - ${new Date().getFullYear()} HirziDevs & Contributors` + + " \n \nDiscord: https://discord.znproject.my.id" + + " \n Source: https://github.com/HirziDevs/PteroStats" + + " \nLicense: https://github.com/Hirzidevs/PteroStats/blob/main/LICENSE" + + ` \n \n${package.description}\n ` +); + +if (!fs.existsSync(".env")) return require("./handlers/installer.js")() + +console.log(cliColor.yellowBright( + "Configuration is already set. Please select one of the following options:\n\n" + + `${cliColor.cyanBright("1")} ${cliColor.blueBright("»")} Start the App\n` + + `${cliColor.cyanBright("2")} ${cliColor.blueBright("»")} Change configuration\n ` +)) + +readline.question('> ', async (answer) => { + readline.close(); + + switch(answer) { + case '2': + require('./handlers/installer.js')(); + break; + case '1': + require('./handlers/app.js')(); + break; + default: + console.log(cliColor.redBright('Invalid input. Please type either 1 or 2.')); + } +}); \ No newline at end of file diff --git a/config.yml b/config.yml index c7eda19..332b35c 100644 --- a/config.yml +++ b/config.yml @@ -10,13 +10,13 @@ presence: status: "online" # Available types: 'online', 'idle', 'dnd', or 'invisible' # Discord Channel and Refresh Timing Configuration -refresh: 10 # Interval in seconds for refreshing the bot's stats. +refresh: 10 # Interval in seconds for refreshing the panel's stats. timeout: 5 # Timeout in seconds for node responses. Adjusting this will affect the overall refresh time. # Message and Embed Configuration # To disable an option, leave the value as an empty string: '' message: - content: "" # Custom content for bot messages. Set to '' to disable. + content: "" # Custom content for app messages. Set to '' to disable. attachment: "" # Attachments will delay stats refresh since they are uploaded first. embed: @@ -36,7 +36,7 @@ embed: nodes: author: - name: "Hosting Panel" + name: "" icon: "" # Icon URL for the author of the nodes embed. title: "Nodes Stats" # Title for the node stats embed. description: "" # Description for the node stats embed. Can be left empty.