feat: add new executable for changing configuration

This commit is contained in:
hirzidevs
2024-09-13 14:16:03 +07:00
parent cbb77ac59d
commit 144deca5e8
2 changed files with 49 additions and 3 deletions

46
config.js Normal file
View File

@@ -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.'));
}
});

View File

@@ -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.