diff --git a/.gitignore b/.gitignore
index 4525073..85f6cee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
-node_modules/
config-dev.yml
package-lock.json
.vscode
node_modules
cache.json
.env
+.setup-complete
\ No newline at end of file
diff --git a/README.md b/README.md
index e255187..ad03be1 100644
--- a/README.md
+++ b/README.md
@@ -14,8 +14,6 @@ PteroStats is a Discord App/Bot designed to check Pterodactyl or Pelican Panel s
-
-
## Guide
- [Starting the App/Bot](#starting-the-appbot)
- [Changing Env Configuration](https://github.com/HirziDevs/PteroStats/blob/main/guide/changing-env-configuration.md)
@@ -30,17 +28,17 @@ PteroStats is a Discord App/Bot designed to check Pterodactyl or Pelican Panel s
1. [Create your Discord App/Bot](https://discordjs.guide/preparations/adding-your-bot-to-servers.html).
2. [Invite your Discord App/Bot to your Discord server](https://discordjs.guide/preparations/adding-your-bot-to-servers.html).
3. Download this repository:
- - [Download this repository](https://github.com/HirziDevs/PteroStats/archive/refs/heads/main.zip) and extract it.
+ - Manually: [Download this repository](https://github.com/HirziDevs/PteroStats/archive/refs/heads/main.zip) and extract it.
- Using Git: Run `git clone https://github.com/HirziDevs/PteroStats.git` in the command line.
4. Run `npm install` in the root directory of the app/bot files.
-5. Run `node index` and answer the prompted questions to set up the app/bot.
+5. Run `node index.js` and answer the prompted questions to set up the app/bot.
- [Getting an Panel API key](https://github.com/HirziDevs/PteroStats/blob/main/guide/getting-panel-api-key.md)
- [Getting a Channel ID](https://github.com/HirziDevs/PteroStats/blob/main/guide/getting-channel-id.md)
-6. Run `node index` if you want to start the app/bot again, and you're done!
+6. Run `node index.js` if you want to start the app/bot again, and you're done!
diff --git a/guide/changing-env-configuration.md b/guide/changing-env-configuration.md
index 345d794..b7c233f 100644
--- a/guide/changing-env-configuration.md
+++ b/guide/changing-env-configuration.md
@@ -2,10 +2,14 @@
> [!TIP]
> You can change other configuration at the `config.yml` file.
-1. Run `node setup` in the root directory of the app/bot files.
-2. Enter `2` to change configuration.
+1. Delete `.setup-complete` file in the root directory of the app/bot files.
+2. Run `node index.js` and answer the prompted questions to set up the app/bot.
-
+
-3. Answer the provided question to set up the app/bot.
-4. Run `node index` if you want to start the app/bot again, and you're done!
\ No newline at end of file
+ - [Getting an Panel API key](https://github.com/HirziDevs/PteroStats/blob/main/guide/getting-panel-api-key.md)
+ - [Getting a Channel ID](https://github.com/HirziDevs/PteroStats/blob/main/guide/getting-channel-id.md)
+
+3. Run `node index.js` if you want to start the app/bot again, and you're done!
+
+
\ No newline at end of file
diff --git a/handlers/setup.js b/handlers/setup.js
index b7275ff..a562622 100644
--- a/handlers/setup.js
+++ b/handlers/setup.js
@@ -1,7 +1,7 @@
-const axios = require("axios")
-const cliColor = require("cli-color")
-const { Client, GatewayIntentBits } = require("discord.js")
-const fs = require("fs")
+const axios = require("axios");
+const cliColor = require("cli-color");
+const { Client, GatewayIntentBits } = require("discord.js");
+const fs = require("node:fs");
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
@@ -82,8 +82,26 @@ module.exports = function Setup() {
console.log(cliColor.green("✓ Valid Discord Bot"));
client.channels.fetch(answers[Question.channelId]).then(() => {
console.log(cliColor.green("✓ Valid Discord Channel"));
- fs.writeFileSync(".env", `PanelURL=${answers[Question.panelUrl]}\nPanelKEY=${answers[Question.panelApiKey]}\nDiscordBotToken=${answers[Question.botToken]}\nDiscordChannel=${answers[Question.channelId]}`, "utf8")
- fs.writeFileSync("config.yml", fs.readFileSync("./config.yml", "utf8").replaceAll("Hosting Panel", answers[0]).replaceAll("https://panel.example.com", answers[1]), "utf-8")
+
+ fs.writeFileSync(".setup-complete", "If you want to re-run the setup process, you can delete this file.", "utf8");
+
+ fs.writeFileSync(
+ ".env",
+ `PanelURL=${answers[Question.panelUrl]}\n` +
+ `PanelKEY=${answers[Question.panelApiKey]}\n` +
+ `DiscordBotToken=${answers[Question.botToken]}\n` +
+ `DiscordChannel=${answers[Question.channelId]}`,
+ "utf8"
+ );
+
+ fs.writeFileSync(
+ "config.yml",
+ fs.readFileSync("./config.yml", "utf8")
+ .replaceAll("Hosting Panel", answers[0])
+ .replaceAll("https://panel.example.com", answers[1]),
+ "utf-8"
+ );
+
console.log(" \n" + cliColor.green(`Configuration saved in ${cliColor.blueBright(".env")} and ${cliColor.blueBright("config.yml")}.\n `));
require("./application.js")()
diff --git a/index.js b/index.js
index 2d73992..7c07717 100644
--- a/index.js
+++ b/index.js
@@ -18,6 +18,6 @@ console.log(
` \n \n${package.description}\n `
);
-if (!fs.existsSync(".env")) return require("./handlers/setup.js")();
+if (!fs.existsSync(".env") || !fs.existsSync(".setup-complete")) return require("./handlers/setup.js")();
-require("./handlers/application.js")();
+require("./handlers/application.js")();
\ No newline at end of file
diff --git a/setup.js b/setup.js
deleted file mode 100644
index 6b026a6..0000000
--- a/setup.js
+++ /dev/null
@@ -1,46 +0,0 @@
-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}`)}`
-);
-
-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/setup.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/setup.js")();
- break;
- case '1':
- require("./handlers/application.js")();
- break;
- default:
- console.log(cliColor.redBright('Invalid input. Please type either 1 or 2.'));
- }
-});