mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 05:04:58 +05:00
Новая версия будет как 4.0
This commit is contained in:
parent
d94a52ebd1
commit
8f3fdb377c
3 changed files with 4 additions and 43 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "jaba",
|
"name": "jaba",
|
||||||
"version": "3.4.7",
|
"version": "4.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "jaba",
|
"name": "jaba",
|
||||||
"version": "3.4.7",
|
"version": "4.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/opus": "^0.7.0",
|
"@discordjs/opus": "^0.7.0",
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
{
|
{
|
||||||
"name": "jaba",
|
"name": "jaba",
|
||||||
"version": "3.4.7",
|
"version": "4.0",
|
||||||
"description": "A very complete Discord bot (more than 100 commands) that uses the Discord.js",
|
"description": "A very complete Discord bot (more than 100 commands) that uses the Discord.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
"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",
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
const chalk = require("chalk");
|
|
||||||
console.log(chalk.blue("Migrating database from v4.6.4 to v4.7.0...\n\n"));
|
|
||||||
|
|
||||||
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 script."));
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const config = require("../config");
|
|
||||||
const dbName = config.mongoDB.split("/").pop();
|
|
||||||
const baseURL = config.mongoDB.substr(0, config.mongoDB.length - dbName.length);
|
|
||||||
const client = new MongoClient(baseURL, {
|
|
||||||
useUnifiedTopology: true
|
|
||||||
});
|
|
||||||
|
|
||||||
client.connect().then(async () => {
|
|
||||||
console.log(chalk.green("Connected successfully to mongoDB database."));
|
|
||||||
|
|
||||||
const db = client.db(dbName);
|
|
||||||
const guilds = db.collection("guilds");
|
|
||||||
|
|
||||||
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: "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..."));
|
|
||||||
process.exit(0);
|
|
||||||
}).catch(() => {
|
|
||||||
console.log(chalk.red("Couldn't connect to mongoDB database..."));
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
Loading…
Reference in a new issue