Fix a bunch of linter errors
diff --git a/src/config/format.ts b/src/config/format.ts
index 03fbd85..3b977fb 100644
--- a/src/config/format.ts
+++ b/src/config/format.ts
@@ -1,21 +1,25 @@
import fs from "fs";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
+// @ts-expect-error
import * as readLine from "node:readline/promises";
const defaultDict = {
- "developmentToken": "Your development bot token (Used for testing in one server, rather than production)",
- "developmentGuildID": "Your development guild ID",
- "enableDevelopment": true,
- "token": "Your bot token",
- "managementGuildID": "Your management guild ID (Used for running management commands on the bot)",
- "owners": [],
- "verifySecret": "If using verify, enter a code here which matches the secret sent back by your website. You can use a random code if you do not have one already. (Optional)",
- "mongoUrl": "Your Mongo connection string, e.g. mongodb://127.0.0.1:27017",
- "baseUrl": "Your website where buttons such as Verify and Role menu will link to, e.g. https://example.com",
- "pastebinApiKey": "An API key for pastebin (optional)",
- "pastebinUsername": "Your pastebin username (optional)",
- "pastebinPassword": "Your pastebin password (optional)"
+ developmentToken:
+ "Your development bot token (Used for testing in one server, rather than production)",
+ developmentGuildID: "Your development guild ID",
+ enableDevelopment: true,
+ token: "Your bot token",
+ managementGuildID:
+ "Your management guild ID (Used for running management commands on the bot)",
+ owners: [],
+ verifySecret:
+ "If using verify, enter a code here which matches the secret sent back by your website. You can use a random code if you do not have one already. (Optional)",
+ mongoUrl: "Your Mongo connection string, e.g. mongodb://127.0.0.1:27017",
+ baseUrl:
+ "Your website where buttons such as Verify and Role menu will link to, e.g. https://example.com",
+ pastebinApiKey: "An API key for pastebin (optional)",
+ pastebinUsername: "Your pastebin username (optional)",
+ pastebinPassword: "Your pastebin password (optional)"
};
const readline = readLine.createInterface({
@@ -30,11 +34,14 @@
return answer.toString();
}
-
-export default async function(walkthrough = false) {
+export default async function (walkthrough = false) {
if (walkthrough) {
- console.log("\x1b[33m🛈 Entering walkthrough mode for any missing values.");
- console.log(" \x1b[2mIf you don't want to enter a value, just hit enter.\x1b[0m\n");
+ console.log(
+ "\x1b[33m🛈 Entering walkthrough mode for any missing values."
+ );
+ console.log(
+ " \x1b[2mIf you don't want to enter a value, just hit enter.\x1b[0m\n"
+ );
// let toUse = await getInput("\x1b[36m[Installing packages] Use Yarn or NPM? \x1b[0m(\x1b[32my\x1b[0m/\x1b[31mN\x1b[0m) > ");
// toUse = toUse.toLowerCase() === "y" ? "yarn install" : "npm i";
@@ -53,7 +60,9 @@
json = JSON.parse(fs.readFileSync("./src/config/main.json", "utf8"));
} catch (e) {
console.log("\x1b[31mâš No main.json found, creating one.");
- console.log(" \x1b[2mYou can edit src/config/main.json directly using template written to the file.\x1b[0m\n");
+ console.log(
+ " \x1b[2mYou can edit src/config/main.json directly using template written to the file.\x1b[0m\n"
+ );
out = false;
json = {};
}
@@ -61,36 +70,58 @@
if (!json[key]) {
if (walkthrough) {
switch (key) {
- case "enableDevelopment": {
- json[key] = (await getInput("\x1b[36mEnable development mode? This registers commands in a single server making it easier to test\x1b[0m(\x1b[32mY\x1b[0m/\x1b[31mn\x1b[0m) > ") || "Y").toLowerCase() === "y"; break;
- } case "owners": {
- let chosen = "!";
- const toWrite = [];
- while (chosen !== "") {
- chosen = await getInput("\x1b[36mEnter an owner ID \x1b[0m(\x1b[35mleave blank to finish\x1b[0m) > ");
- if (chosen !== "") { toWrite.push(chosen); }
+ case "enableDevelopment": {
+ json[key] =
+ (
+ (await getInput(
+ "\x1b[36mEnable development mode? This registers commands in a single server making it easier to test\x1b[0m(\x1b[32mY\x1b[0m/\x1b[31mn\x1b[0m) > "
+ )) || "Y"
+ ).toLowerCase() === "y";
+ break;
}
- json[key] = toWrite; break;
- } default: {
- json[key] = await getInput(`\x1b[36m${key} \x1b[0m(\x1b[35m${defaultDict[key]}\x1b[0m) > `);
+ case "owners": {
+ let chosen = "!";
+ const toWrite = [];
+ while (chosen !== "") {
+ chosen = await getInput(
+ "\x1b[36mEnter an owner ID \x1b[0m(\x1b[35mleave blank to finish\x1b[0m) > "
+ );
+ if (chosen !== "") {
+ toWrite.push(chosen);
+ }
+ }
+ json[key] = toWrite;
+ break;
+ }
+ default: {
+ json[key] = await getInput(
+ `\x1b[36m${key} \x1b[0m(\x1b[35m${defaultDict[key]}\x1b[0m) > `
+ );
+ }
}
- }
+ } else {
+ json[key] = defaultDict[key];
}
- else { json[key] = defaultDict[key]; }
}
}
- if (walkthrough && !json.mongoUrl) json.mongoUrl = "mongodb://127.0.0.1:27017";
+ if (walkthrough && !json.mongoUrl)
+ json.mongoUrl = "mongodb://127.0.0.1:27017";
if (!json.mongoUrl.endsWith("/")) json.mongoUrl += "/";
if (!json.baseUrl.endsWith("/")) json.baseUrl += "/";
let hosts;
try {
hosts = fs.readFileSync("/etc/hosts", "utf8").toString().split("\n");
} catch (e) {
- return console.log("\x1b[31mâš No /etc/hosts found. Please ensure the file exists and is readable. (Windows is not supported, Mac and Linux users should not experience this error)");
+ return console.log(
+ "\x1b[31mâš No /etc/hosts found. Please ensure the file exists and is readable. (Windows is not supported, Mac and Linux users should not experience this error)"
+ );
}
- let localhost = hosts.find(line => line.split(" ")[1] === "localhost");
- if (localhost) { localhost = localhost.split(" ")[0]; }
- else { localhost = "127.0.0.1"; }
+ let localhost = hosts.find((line) => line.split(" ")[1] === "localhost");
+ if (localhost) {
+ localhost = localhost.split(" ")[0];
+ } else {
+ localhost = "127.0.0.1";
+ }
json.mongoUrl = json.mongoUrl.replace("localhost", localhost);
json.baseUrl = json.baseUrl.replace("localhost", localhost);