update scripts

This commit is contained in:
JonnyBro 2021-12-22 19:13:26 +05:00
parent 7049245b12
commit 10bb0a9309
5 changed files with 24 additions and 23 deletions

View file

@ -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>", "stats": "<:atlanta_stats:598179382657286152>",
"ram": "<:atlanta_ram:598178809031688192>", "ram": "<:atlanta_ram:598178809031688192>",

View file

@ -7,7 +7,8 @@
"scripts": { "scripts": {
"start": "node .", "start": "node .",
"lint": "eslint . --ext .js", "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", "author": "Jonny_Bro",
"license": "ISC", "license": "ISC",

View file

@ -6,7 +6,7 @@ let MongoClient;
try { try {
MongoClient = require("mongodb").MongoClient; MongoClient = require("mongodb").MongoClient;
} catch (e) { } 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); process.exit(1);
}; };

View file

@ -6,7 +6,7 @@ let MongoClient;
try { try {
MongoClient = require("mongodb").MongoClient; MongoClient = require("mongodb").MongoClient;
} catch (e) { } 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); process.exit(1);
}; };
@ -23,11 +23,11 @@ client.connect().then(async () => {
const db = client.db(dbName); const db = client.db(dbName);
const guilds = db.collection("guilds"); 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...`)); console.log(chalk.yellow(`${count} guilds need to be migrated. Migrating...`));
await guilds.updateMany({ language: "english" }, { $set: { language: "ru-RU"} }); await guilds.updateMany({ language: "english" }, { $set: { language: "en-US"} });
await guilds.updateMany({ language: "french" }, { $set: { language: "ru-RU"} }); await guilds.updateMany({ language: "russian" }, { $set: { language: "ru-RU"} });
console.log(chalk.green(`${count} guilds migrated.`)); console.log(chalk.green(`${count} guilds migrated.`));
console.log(chalk.blue("\n\nDatabase migrated from v4.6.4 to v4.7.0...")); console.log(chalk.blue("\n\nDatabase migrated from v4.6.4 to v4.7.0..."));

View file

@ -29,16 +29,16 @@ const checks = [
let readyResolve; let readyResolve;
new Promise((resolve) => readyResolve = resolve); new Promise((resolve) => readyResolve = resolve);
client.login(config.token).then(async () => { client.login(config.token).then(async () => {
success("valid bot token"); success("Valid bot token");
await readyResolve(); await readyResolve();
if (!client.guilds.cache.has("568120814776614924")) { 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 { } else {
success("added to the emojis server"); success("Added to the emojis server");
}; };
res(); res();
}).catch(() => { }).catch(() => {
error("should be a valid bot token"); error("Should be a valid bot token");
res(); res();
}); });
client.on("ready", readyResolve); client.on("ready", readyResolve);
@ -57,7 +57,7 @@ const checks = [
success("Connection to Mongo database success"); success("Connection to Mongo database success");
res(); res();
}).catch(() => { }).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(); res();
}); });
}); });
@ -66,7 +66,7 @@ const checks = [
console.log("\n\nAPI keys"); console.log("\n\nAPI keys");
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
if (!config.apiKeys.amethyste) { 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 { } else {
const res = await fetch("https://v1.api.amethyste.moe/generate/blurple", { const res = await fetch("https://v1.api.amethyste.moe/generate/blurple", {
method: "POST", method: "POST",
@ -76,9 +76,9 @@ const checks = [
}); });
const result = await res.json(); const result = await res.json();
if (result.status === 401) { 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 { } else {
success("valid Amethyste API key"); success("Valid Amethyste API key");
}; };
} }
if (!config.apiKeys.blagueXYZ) { if (!config.apiKeys.blagueXYZ) {
@ -91,9 +91,9 @@ const checks = [
}); });
const result = await res.json(); const result = await res.json();
if (result.status === 401) { 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 { } else {
success("valid blague.xyz key"); success("Valid blague.xyz key");
}; };
}; };
if (!config.apiKeys.dbl) { if (!config.apiKeys.dbl) {
@ -107,9 +107,9 @@ const checks = [
}); });
const result = await res.json(); const result = await res.json();
if (result.error && result.error === "Unauthorized") { 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 { } else {
success("valid DBL key"); success("Valid DBL key");
}; };
}; };
if (!config.apiKeys.fortniteFNBR) { if (!config.apiKeys.fortniteFNBR) {
@ -122,9 +122,9 @@ const checks = [
}); });
const result = await res.json(); const result = await res.json();
if (result.status && result.status === 401) { 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 { } else {
success("valid FNBR key"); success("Valid FNBR key");
}; };
}; };
if (!config.apiKeys.sentryDSN) { if (!config.apiKeys.sentryDSN) {
@ -167,9 +167,9 @@ const checks = [
}; };
const isPortTaken = await checkPortTaken(config.dashboard.port); const isPortTaken = await checkPortTaken(config.dashboard.port);
if (isPortTaken) { 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 { } else {
success("dashboard port is available"); success("Dashboard port is available");
}; };
}; };
resolve(); resolve();