From 10bb0a9309e2d56d653f6501f9a12d31e4e11ac4 Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Wed, 22 Dec 2021 19:13:26 +0500 Subject: [PATCH] update scripts --- emojis.json | 2 +- package.json | 3 ++- scripts/create-db-indexes.js | 2 +- scripts/migrate-db-from-v4.6-to-v4.7.js | 8 +++---- scripts/verify-config.js | 32 ++++++++++++------------- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/emojis.json b/emojis.json index b3691657..334c5af9 100644 --- a/emojis.json +++ b/emojis.json @@ -1,5 +1,5 @@ { - "To get access to these emojis,": "add your bot on https://emojis.atlanta-bot.fr", + "To get access to these emojis,": "add your bot on https://discord.gg/5wrBEwE4bc", "stats": "<:atlanta_stats:598179382657286152>", "ram": "<:atlanta_ram:598178809031688192>", diff --git a/package.json b/package.json index e9ac874c..bb8a913f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "scripts": { "start": "node .", "lint": "eslint . --ext .js", - "testcfg": "node scripts/verify-config.js" + "testcfg": "node scripts/verify-config.js", + "migratedb": "node scripts/migrate-db-from-v4.6-to-v4.7.js" }, "author": "Jonny_Bro", "license": "ISC", diff --git a/scripts/create-db-indexes.js b/scripts/create-db-indexes.js index 196813c5..96ef65a7 100644 --- a/scripts/create-db-indexes.js +++ b/scripts/create-db-indexes.js @@ -6,7 +6,7 @@ let MongoClient; try { MongoClient = require("mongodb").MongoClient; } catch (e) { - console.log(chalk.red("Cannot find module mongodb. Please install it using \"npm install mongodb\" before executing migration scripts.")); + console.log(chalk.red("Cannot find module mongodb. Please install it using \"npm install mongodb\" before executing script.")); process.exit(1); }; diff --git a/scripts/migrate-db-from-v4.6-to-v4.7.js b/scripts/migrate-db-from-v4.6-to-v4.7.js index 6af0236f..98e5a0f1 100644 --- a/scripts/migrate-db-from-v4.6-to-v4.7.js +++ b/scripts/migrate-db-from-v4.6-to-v4.7.js @@ -6,7 +6,7 @@ let MongoClient; try { MongoClient = require("mongodb").MongoClient; } catch (e) { - console.log(chalk.red("Cannot find module mongodb. Please install it using \"npm install mongodb\" before executing migration scripts.")); + console.log(chalk.red("Cannot find module mongodb. Please install it using \"npm install mongodb\" before executing script.")); process.exit(1); }; @@ -23,11 +23,11 @@ client.connect().then(async () => { const db = client.db(dbName); const guilds = db.collection("guilds"); - const count = await guilds.countDocuments({ $or: [ { language: "english" }, { language: "french" } ] }); + const count = await guilds.countDocuments({ $or: [ { language: "english" }, { language: "russian" } ] }); console.log(chalk.yellow(`${count} guilds need to be migrated. Migrating...`)); - await guilds.updateMany({ language: "english" }, { $set: { language: "ru-RU"} }); - await guilds.updateMany({ language: "french" }, { $set: { language: "ru-RU"} }); + await guilds.updateMany({ language: "english" }, { $set: { language: "en-US"} }); + await guilds.updateMany({ language: "russian" }, { $set: { language: "ru-RU"} }); console.log(chalk.green(`${count} guilds migrated.`)); console.log(chalk.blue("\n\nDatabase migrated from v4.6.4 to v4.7.0...")); diff --git a/scripts/verify-config.js b/scripts/verify-config.js index e62a2b1d..8d62f321 100644 --- a/scripts/verify-config.js +++ b/scripts/verify-config.js @@ -29,16 +29,16 @@ const checks = [ let readyResolve; new Promise((resolve) => readyResolve = resolve); client.login(config.token).then(async () => { - success("valid bot token"); + success("Valid bot token"); await readyResolve(); if (!client.guilds.cache.has("568120814776614924")) { - error("should be added to the emojis server", "please add your bot on this server: https://emojis.atlanta-bot.fr to make the emojis working"); + error("Should be added to the emojis server", "please add your bot on this server: https://discord.gg/5wrBEwE4bc to make the emojis working"); } else { - success("added to the emojis server"); + success("Added to the emojis server"); }; res(); }).catch(() => { - error("should be a valid bot token"); + error("Should be a valid bot token"); res(); }); client.on("ready", readyResolve); @@ -57,7 +57,7 @@ const checks = [ success("Connection to Mongo database success"); res(); }).catch(() => { - error("should be able to connect to Mongo database", "please verify if the MongoDB server is started"); + error("Should be able to connect to Mongo database", "please verify if the MongoDB server is started"); res(); }); }); @@ -66,7 +66,7 @@ const checks = [ console.log("\n\nAPI keys"); return new Promise(async (resolve) => { if (!config.apiKeys.amethyste) { - ignore("amethyste API is not configured, key should not be checked."); + ignore("Amethyste API is not configured, key should not be checked."); } else { const res = await fetch("https://v1.api.amethyste.moe/generate/blurple", { method: "POST", @@ -76,9 +76,9 @@ const checks = [ }); const result = await res.json(); if (result.status === 401) { - error("should be a valid Amethyste API key", "get your key here: https://api.amethyste.moe/"); + error("Should be a valid Amethyste API key", "get your key here: https://api.amethyste.moe/"); } else { - success("valid Amethyste API key"); + success("Valid Amethyste API key"); }; } if (!config.apiKeys.blagueXYZ) { @@ -91,9 +91,9 @@ const checks = [ }); const result = await res.json(); if (result.status === 401) { - error("should be a valid blague.xyz key", "get your key here: https://blague.xyz/"); + error("Should be a valid blague.xyz key", "get your key here: https://blague.xyz/"); } else { - success("valid blague.xyz key"); + success("Valid blague.xyz key"); }; }; if (!config.apiKeys.dbl) { @@ -107,9 +107,9 @@ const checks = [ }); const result = await res.json(); if (result.error && result.error === "Unauthorized") { - error("should be a valid DBL key", "get your key here: https://top.gg/ OR delete the key from the config if you don't have a key"); + error("Should be a valid DBL key", "get your key here: https://top.gg/ OR delete the key from the config if you don't have a key"); } else { - success("valid DBL key"); + success("Valid DBL key"); }; }; if (!config.apiKeys.fortniteFNBR) { @@ -122,9 +122,9 @@ const checks = [ }); const result = await res.json(); if (result.status && result.status === 401) { - error("should be a valid FNBR key", "get your key here: https://fnbr.co/api/docs"); + error("Should be a valid FNBR key", "get your key here: https://fnbr.co/api/docs"); } else { - success("valid FNBR key"); + success("Valid FNBR key"); }; }; if (!config.apiKeys.sentryDSN) { @@ -167,9 +167,9 @@ const checks = [ }; const isPortTaken = await checkPortTaken(config.dashboard.port); if (isPortTaken) { - error("dashboard port should be available", "you have probably another process using this port"); + error("Dashboard port should be available", "you have probably another process using this port"); } else { - success("dashboard port is available"); + success("Dashboard port is available"); }; }; resolve();