diff --git a/base/Guild.js b/base/Guild.js index b72f1083..3fb5f368 100644 --- a/base/Guild.js +++ b/base/Guild.js @@ -31,12 +31,18 @@ module.exports = mongoose.model("Guild", new Schema({ ignored: [], }, warnsSanctions: { - kick: false, - ban: false, + kick: null, + ban: null, }, - suggestions: false, - reports: false, - birthdays: false, - modlogs: false, + monitoring: { + memberAdd: null, + memberLeave: null, + memberUpdate: null, + messageUpdate: null, + }, + suggestions: null, + reports: null, + birthdays: null, + modlogs: null, } }, })); \ No newline at end of file diff --git a/base/JaBa.js b/base/JaBa.js index 7f8086a2..d05a7dd7 100644 --- a/base/JaBa.js +++ b/base/JaBa.js @@ -243,29 +243,24 @@ class JaBa extends Client { /** * Find or create user in DB * @param {Array} param0 { id: User ID } - * @param {Boolean} isLean Return JSON instead Mongoose model? * @returns {import("./User")} Mongoose model or JSON of this user */ - async findOrCreateUser({ id: userID }, isLean) { - if (this.databaseCache.users.get(userID)) return isLean ? this.databaseCache.users.get(userID).toJSON() : this.databaseCache.users.get(userID); + async findOrCreateUser({ id: userID }) { + if (this.databaseCache.users.get(userID)) return this.databaseCache.users.get(userID); else { - let userData = (isLean ? await this.usersData.findOne({ - id: userID, - }).lean() : await this.usersData.findOne({ - id: userID, - })); + let userData = await this.usersData.findOne({ id: userID }); + if (userData) { - if (!isLean) this.databaseCache.users.set(userID, userData); + this.databaseCache.users.set(userID, userData); return userData; } else { - userData = new this.usersData({ - id: userID, - }); + userData = new this.usersData({ id: userID }); await userData.save(); + this.databaseCache.users.set(userID, userData); - return isLean ? userData.toJSON() : userData; + return userData; } } } @@ -273,70 +268,53 @@ class JaBa extends Client { /** * Find or create member in DB * @param {Array} param0 { id: Member ID } - * @param {Boolean} isLean Return JSON instead Mongoose model? * @returns {import("./Member")} Mongoose model or JSON of this member */ - async findOrCreateMember({ id: memberID, guildId }, isLean) { - if (this.databaseCache.members.get(`${memberID}${guildId}`)) return isLean ? this.databaseCache.members.get(`${memberID}${guildId}`).toJSON() : this.databaseCache.members.get(`${memberID}${guildId}`); - else { - let memberData = (isLean ? await this.membersData.findOne({ - guildID: guildId, - id: memberID, - }).lean() : await this.membersData.findOne({ - guildID: guildId, - id: memberID, - })); - if (memberData) { - if (!isLean) this.databaseCache.members.set(`${memberID}${guildId}`, memberData); + async findOrCreateMember({ id: memberID, guildId }) { + let memberData = await this.membersData.findOne({ guildID: guildId, id: memberID }); - return memberData; - } else { - memberData = new this.membersData({ - id: memberID, - guildID: guildId, - }); - await memberData.save(); - const guild = await this.findOrCreateGuild({ - id: guildId, - }); - if (guild) { - guild.members.push(memberData._id); - await guild.save(); - } - this.databaseCache.members.set(`${memberID}${guildId}`, memberData); + if (memberData) { + this.databaseCache.members.set(`${memberID}${guildId}`, memberData); - return isLean ? memberData.toJSON() : memberData; + return memberData; + } else { + memberData = new this.membersData({ id: memberID, guildID: guildId }); + await memberData.save(); + + const guildData = await this.findOrCreateGuild({ id: guildId }); + + if (guildData) { + guildData.members.push(memberData._id); + guildData.markModified("members"); + + await guildData.save(); } + + this.databaseCache.members.set(`${memberID}${guildId}`, memberData); + + return memberData; } } /** * Find or create guild in DB * @param {Array} param0 { id: Guild ID } - * @param {Boolean} isLean Return JSON instead Mongoose model? * @returns {import("./Guild")} Mongoose model or JSON of this guild */ - async findOrCreateGuild({ id: guildId }, isLean) { - if (this.databaseCache.guilds.get(guildId)) return isLean ? this.databaseCache.guilds.get(guildId).toJSON() : this.databaseCache.guilds.get(guildId); - else { - let guildData = (isLean ? await this.guildsData.findOne({ - id: guildId, - }).populate("members").lean() : await this.guildsData.findOne({ - id: guildId, - }).populate("members")); - if (guildData) { - if (!isLean) this.databaseCache.guilds.set(guildId, guildData); + async findOrCreateGuild({ id: guildId }) { + let guildData = await this.guildsData.findOne({ id: guildId }).populate("members"); - return guildData; - } else { - guildData = new this.guildsData({ - id: guildId, - }); - await guildData.save(); - this.databaseCache.guilds.set(guildId, guildData); + if (guildData) { + this.databaseCache.guilds.set(guildId, guildData); - return isLean ? guildData.toJSON() : guildData; - } + return guildData; + } else { + guildData = new this.guildsData({ id: guildId }); + await guildData.save(); + + this.databaseCache.guilds.set(guildId, guildData); + + return guildData; } } } diff --git a/commands/!DISABLED/importmee6.js b/commands/!DISABLED/importmee6.js index 73339d4f..4896d8e1 100644 --- a/commands/!DISABLED/importmee6.js +++ b/commands/!DISABLED/importmee6.js @@ -38,6 +38,7 @@ class ImportMee6 extends BaseCommand { const level = (await Mee6Api.getUserXp(interaction.guildId, interaction.member)).level; data.memberData.level = level; + data.markModified("memberData.level"); await data.memberData.save(); interaction.editReply({ diff --git a/commands/Administration/config.js b/commands/Administration/config.js index 15a4e157..85243a8b 100644 --- a/commands/Administration/config.js +++ b/commands/Administration/config.js @@ -41,6 +41,7 @@ class Config extends BaseCommand { { name: client.translate("administration/config:MODLOGS"), value: "modlogs" }, { name: client.translate("administration/config:REPORTS"), value: "reports" }, { name: client.translate("administration/config:SUGGESTIONS"), value: "suggestions" }, + { name: client.translate("administration/config:MESSAGEUPDATE"), value: "monitoring.messageUpdate" }, ) .setRequired(true)) .addBooleanOption(option => option.setName("state") @@ -126,20 +127,18 @@ class Config extends BaseCommand { channels: guildData.plugins.automod.ignored.map(ch => ` ${ch}`), }) : interaction.translate("common:DISABLED"), }, + { + name: interaction.translate("administration/config:MONITORING_CHANNELS"), + value: + `${interaction.translate("administration/config:MESSAGEUPDATE")}: ${guildData.plugins.monitoring.messageUpdate ? `<#${guildData.plugins.monitoring.messageUpdate}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n`, + }, { name: interaction.translate("administration/config:SPECIAL_CHANNELS"), - value: interaction.translate("administration/config:SUGGESTIONS_LIST", { - channel: guildData.plugins.suggestions ? `<#${guildData.plugins.suggestions}>` : `*${interaction.translate("common:NOT_DEFINED")}*`, - }) + "\n" + - interaction.translate("administration/config:REPORTS_LIST", { - channel: guildData.plugins.reports ? `<#${guildData.plugins.reports}>` : `*${interaction.translate("common:NOT_DEFINED")}*`, - }) + "\n" + - interaction.translate("administration/config:MODLOGS_LIST", { - channel: guildData.plugins.modlogs ? `<#${guildData.plugins.modlogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*`, - }) + "\n" + - interaction.translate("administration/config:BIRTHDAYS_LIST", { - channel: guildData.plugins.birthdays ? `<#${guildData.plugins.birthdays}>` : `*${interaction.translate("common:NOT_DEFINED")}*`, - }), + value: + `${interaction.translate("administration/config:SUGGESTIONS")}: ${guildData.plugins.suggestions ? `<#${guildData.plugins.suggestions}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` + + `${interaction.translate("administration/config:REPORTS")}: ${guildData.plugins.reports ? `<#${guildData.plugins.reports}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` + + `${interaction.translate("administration/config:MODLOGS")}: ${guildData.plugins.modlogs ? `<#${guildData.plugins.modlogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` + + `${interaction.translate("administration/config:BIRTHDAYS")}: ${guildData.plugins.birthdays ? `<#${guildData.plugins.birthdays}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}`, }, { name: interaction.translate("administration/config:DASHBOARD_TITLE"), diff --git a/commands/Administration/set.js b/commands/Administration/set.js index a6bd97b8..906510b0 100644 --- a/commands/Administration/set.js +++ b/commands/Administration/set.js @@ -78,7 +78,9 @@ class Set extends BaseCommand { switch (type) { case "level": { memberData.level = int; + memberData.markModified("level"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -87,7 +89,9 @@ class Set extends BaseCommand { case "xp": { memberData.exp = int; + memberData.markModified("exp"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -96,7 +100,9 @@ class Set extends BaseCommand { case "credits": { memberData.money = int; + memberData.markModified("money"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -105,7 +111,9 @@ class Set extends BaseCommand { case "bank": { memberData.bankSold = int; + memberData.markModified("bankSold"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, diff --git a/commands/Administration/setlang.js b/commands/Administration/setlang.js index 446830c4..c8eb17a0 100644 --- a/commands/Administration/setlang.js +++ b/commands/Administration/setlang.js @@ -52,6 +52,7 @@ class Setlang extends BaseCommand { language = client.languages.find(l => l.name === lang); data.guildData.language = language.name; + data.guildData.markModified("language"); await data.guildData.save(); return interaction.success("administration/setlang:SUCCESS", { diff --git a/commands/Economy/bank.js b/commands/Economy/bank.js index da217160..589023e7 100644 --- a/commands/Economy/bank.js +++ b/commands/Economy/bank.js @@ -62,6 +62,8 @@ class Bank extends BaseCommand { data.memberData.money -= credits; data.memberData.bankSold += credits; + data.memberData.markModified("money"); + data.memberData.markModified("bankSold"); await data.memberData.save(); const info = { @@ -91,6 +93,8 @@ class Bank extends BaseCommand { data.memberData.money += credits; data.memberData.bankSold -= credits; + data.memberData.markModified("money"); + data.memberData.markModified("bankSold"); await data.memberData.save(); interaction.success("economy/bank:SUCCESS_WD", { diff --git a/commands/Economy/birthdate.js b/commands/Economy/birthdate.js index 1bb3bc75..74197d07 100644 --- a/commands/Economy/birthdate.js +++ b/commands/Economy/birthdate.js @@ -80,6 +80,7 @@ class Birthdate extends BaseCommand { if (d.getTime() < (Date.now() - 2.523e+12)) return interaction.error("economy/birthdate:DATE_TOO_LOW"); data.userData.birthdate = d; + data.userData.markModified("birthdate"); await data.userData.save(); interaction.success("economy/birthdate:SUCCESS", { diff --git a/commands/Economy/divorce.js b/commands/Economy/divorce.js index f7315953..4b8445b1 100644 --- a/commands/Economy/divorce.js +++ b/commands/Economy/divorce.js @@ -39,12 +39,14 @@ class Divorce extends BaseCommand { const user = client.users.cache.get(data.userData.lover) || await client.users.fetch(data.userData.lover); data.userData.lover = null; + data.user.markModified("lover"); await data.userData.save(); const oldLover = await client.findOrCreateUser({ id: user.id, }); oldLover.lover = null; + oldLover.markModified("lover"); await oldLover.save(); interaction.success("economy/divorce:DIVORCED", { diff --git a/commands/Economy/marry.js b/commands/Economy/marry.js index e05fdbb2..6e8f9c1d 100644 --- a/commands/Economy/marry.js +++ b/commands/Economy/marry.js @@ -128,8 +128,11 @@ class Marry extends BaseCommand { if (reason) { data.userData.lover = member.id; - await data.userData.save(); userData.lover = interaction.member.id; + + data.userData.markModified("lover"); + await data.userData.save(); + userData.markModified("lover"); await userData.save(); const messageOptions = { diff --git a/commands/Economy/pay.js b/commands/Economy/pay.js index f19f6b26..a261cf31 100644 --- a/commands/Economy/pay.js +++ b/commands/Economy/pay.js @@ -65,9 +65,11 @@ class Pay extends BaseCommand { }); data.memberData.money -= amount; + data.memberData.markModified("money"); await data.memberData.save(); memberData.money += amount; + memberData.markModified("money"); await memberData.save(); const info1 = { diff --git a/commands/Economy/rob.js b/commands/Economy/rob.js index 3e833229..cc994b20 100644 --- a/commands/Economy/rob.js +++ b/commands/Economy/rob.js @@ -91,8 +91,11 @@ class Rob extends BaseCommand { data.memberData.money += amount; memberData.money -= amount; - await memberData.save(); + data.memberData.markModified("money"); + memberData.markModified("money"); + await data.memberData.save(); + await memberData.save(); } else { const won = Math.floor(amount * 0.9), randomNum = client.functions.randomNum(1, 2); @@ -106,8 +109,11 @@ class Rob extends BaseCommand { data.memberData.money -= potentiallyLose; memberData.money += won; - await memberData.save(); + data.memberData.markModified("money"); + memberData.markModified("money"); + await data.memberData.save(); + await memberData.save(); } } } diff --git a/commands/Economy/setbio.js b/commands/Economy/setbio.js index 254ac382..1c40b4e2 100644 --- a/commands/Economy/setbio.js +++ b/commands/Economy/setbio.js @@ -46,7 +46,9 @@ class Setbio extends BaseCommand { if (newBio.length > 150) return interaction.error("economy/setbio:MAX_CHARACTERS"); data.userData.bio = newBio; + data.memberData.markModified("bio"); await data.userData.save(); + interaction.success("economy/setbio:SUCCESS"); } } diff --git a/commands/Economy/slots.js b/commands/Economy/slots.js index 061e39a8..02639c5a 100644 --- a/commands/Economy/slots.js +++ b/commands/Economy/slots.js @@ -109,16 +109,19 @@ class Slots extends BaseCommand { const toAdd = credits - amount; - data.memberData.money += toAdd; - const info = { user: interaction.translate("economy/slots:DESCRIPTION"), amount: toAdd, date: Date.now(), type: "got", }; + + data.memberData.money += toAdd; data.memberData.transactions.push(info); + data.memberData.markModified("money"); + data.memberData.markModified("transactions"); + if (!data.userData.achievements.slots.achieved) { data.userData.achievements.slots.progress.now += 1; if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) { @@ -134,6 +137,7 @@ class Slots extends BaseCommand { await data.userData.save(); } await data.memberData.save(); + return; } @@ -159,8 +163,12 @@ class Slots extends BaseCommand { date: Date.now(), type: "got", }; - data.memberData.transactions.push(info); + data.memberData.money += toAdd; + data.memberData.transactions.push(info); + + data.memberData.markModified("money"); + data.memberData.markModified("transactions"); if (!data.userData.achievements.slots.achieved) { data.userData.achievements.slots.progress.now += 1; @@ -194,8 +202,12 @@ class Slots extends BaseCommand { date: Date.now(), type: "send", }; - data.memberData.transactions.push(info); + data.memberData.money -= amount; + data.memberData.transactions.push(info); + + data.memberData.markModified("money"); + data.memberData.markModified("transactions"); if (!data.userData.achievements.slots.achieved) { data.userData.achievements.slots.progress.now = 0; diff --git a/commands/Economy/transactions.js b/commands/Economy/transactions.js index 7e473669..318a887a 100644 --- a/commands/Economy/transactions.js +++ b/commands/Economy/transactions.js @@ -43,6 +43,7 @@ class Transactions extends BaseCommand { async execute(client, interaction, data) { if (interaction.options.getBoolean("clear")) { data.memberData.transactions = []; + data.memberData.markModified("transactions"); await data.memberData.save(); return interaction.success("economy/transactions:CLEARED", null, { ephemeral: true }); diff --git a/commands/Economy/work.js b/commands/Economy/work.js index 2f6b1253..5bc4c187 100644 --- a/commands/Economy/work.js +++ b/commands/Economy/work.js @@ -103,6 +103,7 @@ class Work extends BaseCommand { } data.memberData.money += won; + data.memberData.markModified("money"); await data.memberData.save(); const info = { diff --git a/commands/Fun/number.js b/commands/Fun/number.js index a776018e..04b32d97 100644 --- a/commands/Fun/number.js +++ b/commands/Fun/number.js @@ -96,6 +96,7 @@ class Number extends BaseCommand { }; data.memberData.transactions.push(info); + data.memberData.markModified("transactions"); await memberData.save(); } collector.stop(); diff --git a/commands/Fun/tictactoe.js b/commands/Fun/tictactoe.js index e3ef5c59..312667bd 100644 --- a/commands/Fun/tictactoe.js +++ b/commands/Fun/tictactoe.js @@ -54,6 +54,7 @@ class TicTacToe extends BaseCommand { }); memberData.money += 100; + memberData.markModified("money"); await memberData.save(); const info = { diff --git a/commands/General/afk.js b/commands/General/afk.js index bb8a28c2..bd6e73e6 100644 --- a/commands/General/afk.js +++ b/commands/General/afk.js @@ -47,6 +47,7 @@ class Afk extends BaseCommand { const reason = interaction.options.getString("message"); data.userData.afk = reason; + data.userData.markModified("afk"); await data.userData.save(); interaction.success("general/afk:SUCCESS", { diff --git a/commands/Moderation/clearwarns.js b/commands/Moderation/clearwarns.js index 27943877..cd22f432 100644 --- a/commands/Moderation/clearwarns.js +++ b/commands/Moderation/clearwarns.js @@ -51,6 +51,7 @@ class Clearwarns extends BaseCommand { }); memberData.sanctions = []; + memberData.markModified("sanctions"); memberData.save(); interaction.success("moderation/clearwarns:SUCCESS", { diff --git a/commands/Moderation/warn.js b/commands/Moderation/warn.js index 9b56df76..0e1ee31a 100644 --- a/commands/Moderation/warn.js +++ b/commands/Moderation/warn.js @@ -178,6 +178,7 @@ class Warn extends BaseCommand { .setColor(client.config.embed.color); memberData.sanctions.push(caseInfo); + memberData.markModified("sanctions"); memberData.save(); if (data.guildData.plugins.modlogs) { diff --git a/commands/Owner/debug.js b/commands/Owner/debug.js index 730e517a..d1e0a3de 100644 --- a/commands/Owner/debug.js +++ b/commands/Owner/debug.js @@ -126,7 +126,9 @@ class Debug extends BaseCommand { switch (type) { case "level": { memberData.level = int; + memberData.markModified("level"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -135,7 +137,9 @@ class Debug extends BaseCommand { case "xp": { memberData.exp = int; + memberData.markModified("exp"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -144,7 +148,9 @@ class Debug extends BaseCommand { case "credits": { memberData.money = int; + memberData.markModified("money"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -153,7 +159,9 @@ class Debug extends BaseCommand { case "bank": { memberData.bankSold = int; + memberData.markModified("bankSold"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -162,7 +170,9 @@ class Debug extends BaseCommand { case "rep": { userData.rep = int; + userData.markModified("rep"); await userData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -187,7 +197,9 @@ class Debug extends BaseCommand { switch (type) { case "level": { memberData.level += int; + memberData.markModified("level"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -196,7 +208,9 @@ class Debug extends BaseCommand { case "xp": { memberData.exp += int; + memberData.markModified("exp"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -205,7 +219,9 @@ class Debug extends BaseCommand { case "credits": { memberData.money += int; + memberData.markModified("money"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -214,7 +230,9 @@ class Debug extends BaseCommand { case "bank": { memberData.bankSold += int; + memberData.markModified("bankSold"); await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, @@ -223,7 +241,9 @@ class Debug extends BaseCommand { case "rep": { userData.rep += int; + userData.markModified("rep"); await userData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { user: member.toString(), amount: int, diff --git a/commands/Owner/eval.js b/commands/Owner/eval.js index faaba0c9..1a6e7086 100644 --- a/commands/Owner/eval.js +++ b/commands/Owner/eval.js @@ -49,7 +49,7 @@ class Eval extends BaseCommand { const result = new Promise(resolve => resolve(eval(code))); return result.then(output => { - if (typeof output != "string") output = require("util").inspect(output, { depth: 0 }); + if (typeof output !== "string") output = require("util").inspect(output); if (output.includes(client.token)) output = output.replace(client.token, "T0K3N"); interaction.editReply({ diff --git a/dashboard/dashboard.js b/dashboard/dashboard.js index 784b0973..6935321b 100644 --- a/dashboard/dashboard.js +++ b/dashboard/dashboard.js @@ -240,6 +240,7 @@ module.exports.load = async client => { }); guildData.language = newData; + guildData.markModified("language"); await guildData.save(); return; @@ -268,6 +269,7 @@ module.exports.load = async client => { }); guildData.plugins.welcome.enabled = newData; + guildData.markModified("plugins.welcome"); await guildData.save(); return; @@ -291,6 +293,7 @@ module.exports.load = async client => { }); guildData.plugins.welcome.withImage = newData; + guildData.markModified("plugins.welcome"); await guildData.save(); return; @@ -314,6 +317,7 @@ module.exports.load = async client => { }); guildData.plugins.welcome.message = newData !== "" ? newData : null; + guildData.markModified("plugins.welcome"); await guildData.save(); return; @@ -337,6 +341,7 @@ module.exports.load = async client => { }); guildData.plugins.welcome.channel = newData !== "" ? newData : null; + guildData.markModified("plugins.welcome"); await guildData.save(); return; @@ -367,6 +372,7 @@ module.exports.load = async client => { }); guildData.plugins.goodbye.enabled = newData; + guildData.markModified("plugins.goodbye"); await guildData.save(); return; @@ -390,6 +396,7 @@ module.exports.load = async client => { }); guildData.plugins.goodbye.withImage = newData; + guildData.markModified("plugins.goodbye"); await guildData.save(); return; @@ -413,6 +420,7 @@ module.exports.load = async client => { }); guildData.plugins.goodbye.message = newData !== "" ? newData : null; + guildData.markModified("plugins.goodbye"); await guildData.save(); return; @@ -436,6 +444,7 @@ module.exports.load = async client => { }); guildData.plugins.goodbye.channel = newData !== "" ? newData : null; + guildData.markModified("plugins.goodbye"); await guildData.save(); return; @@ -466,6 +475,7 @@ module.exports.load = async client => { }); guildData.plugins.autorole.enabled = newData; + guildData.markModified("plugins.autorole"); await guildData.save(); return; @@ -489,6 +499,7 @@ module.exports.load = async client => { }); guildData.plugins.autorole.role = newData !== "" ? newData : null; + guildData.markModified("plugins.autorole"); await guildData.save(); return; @@ -519,6 +530,7 @@ module.exports.load = async client => { }); guildData.plugins.automod.enabled = newData; + guildData.markModified("plugins.automod"); await guildData.save(); return; @@ -526,8 +538,8 @@ module.exports.load = async client => { }, { optionId: "automod_ignore", - optionName: "Ignore channels", - optionDescription: "Select channels for auto mod to ignore", + optionName: "Ignore Channels", + optionDescription: "Select a channels for auto mod to ignore", optionType: DBD.formTypes.channelsMultiSelect(false, false, [ ChannelType.GuildText ]), getActualSet: async ({ guild }) => { const guildData = await client.findOrCreateGuild({ @@ -542,6 +554,38 @@ module.exports.load = async client => { }); guildData.plugins.automod.ignored = newData; + guildData.markModified("plugins.automod"); + await guildData.save(); + + return; + }, + }, + ]), + }, + { + optionId: "monitoring", + optionName: "Monitoring Channels", + optionDescription: "Setup monitoring channels on the server", + optionType: SoftUI.formTypes.multiRow([ + { + optionId: "monitoring_messageupdate", + optionName: "Message Update Channel", + optionDescription: "Select a channel for messages updates logs to go to", + optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.monitoring.messageUpdate; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.monitoring.messageUpdate = newData !== "" ? newData : null; + guildData.markModified("plugins.monitoring"); await guildData.save(); return; @@ -556,8 +600,8 @@ module.exports.load = async client => { optionType: SoftUI.formTypes.multiRow([ { optionId: "channels_suggestions", - optionName: "Suggestions channel", - optionDescription: "Select channel for suggestions to go to", + optionName: "Suggestions Channel", + optionDescription: "Select a channel for suggestions to go to", optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), getActualSet: async ({ guild }) => { const guildData = await client.findOrCreateGuild({ @@ -571,7 +615,8 @@ module.exports.load = async client => { id: guild.id, }); - guildData.plugins.suggestions = newData; + guildData.plugins.suggestions = newData !== "" ? newData : null; + guildData.markModified("plugins.suggestions"); await guildData.save(); return; @@ -579,8 +624,8 @@ module.exports.load = async client => { }, { optionId: "channels_reports", - optionName: "Reports channel", - optionDescription: "Select channel for reports to go to", + optionName: "Reports Channel", + optionDescription: "Select a channel for reports to go to", optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), getActualSet: async ({ guild }) => { const guildData = await client.findOrCreateGuild({ @@ -594,7 +639,8 @@ module.exports.load = async client => { id: guild.id, }); - guildData.plugins.reports = newData; + guildData.plugins.reports = newData !== "" ? newData : null; + guildData.markModified("plugins.reports"); await guildData.save(); return; @@ -602,8 +648,8 @@ module.exports.load = async client => { }, { optionId: "channels_birthdays", - optionName: "Birthdays channel", - optionDescription: "Select channel for birthdays message to go to", + optionName: "Birthdays Channel", + optionDescription: "Select a channel for birthdays message to go to", optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), getActualSet: async ({ guild }) => { const guildData = await client.findOrCreateGuild({ @@ -617,7 +663,8 @@ module.exports.load = async client => { id: guild.id, }); - guildData.plugins.birthdays = newData; + guildData.plugins.birthdays = newData !== "" ? newData : null; + guildData.markModified("plugins.birthdays"); await guildData.save(); return; @@ -625,8 +672,8 @@ module.exports.load = async client => { }, { optionId: "channels_modlogs", - optionName: "Moderation logs channel", - optionDescription: "Select channel for moderation logs to go to (warns)", + optionName: "Moderation Logs Channel", + optionDescription: "Select a channel for moderation logs to go to (warns)", optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), getActualSet: async ({ guild }) => { const guildData = await client.findOrCreateGuild({ @@ -640,7 +687,8 @@ module.exports.load = async client => { id: guild.id, }); - guildData.plugins.modlogs = newData; + guildData.plugins.modlogs = newData !== "" ? newData : null; + guildData.markModified("plugins.modlogs"); await guildData.save(); return; @@ -661,11 +709,6 @@ module.exports.load = async client => { username: "JaBa", avatarURL: "https://cdn.discordapp.com/avatars/708637495054565426/af98d49ebc9bf28b40b45ed5a0a623b4.png?size=4096", }), - setNew: async ({ guild, user, newData }) => { - console.log(guild); - console.log(user); - console.log(newData); - }, }, ], }, diff --git a/dashboard/docs/updates.md b/dashboard/docs/updates.md index 8375a0cb..de26caf3 100644 --- a/dashboard/docs/updates.md +++ b/dashboard/docs/updates.md @@ -1,3 +1,11 @@ +### JaBa v4.3.1 +* Добавлено + * Мониторинг изменения сообщений!\ + Скоро добавлю другие эвенты, по типу входа, выхода, обновление участника. + +* Исправления + * Серьёзная ошибка, из-за которой данные не сохранялись в базу данных 🤯. + ### JaBa v4.3.0 * Добавлено * Полностью переделанная панель управления!\ @@ -53,7 +61,7 @@ * *seek* теперь работает нормально. * Переписана команда *clips*. -* Исправление +* Исправления * Старые баги. * Добавлено diff --git a/events/CommandHandler.js b/events/CommandHandler.js index f18a8064..2af5e2b9 100644 --- a/events/CommandHandler.js +++ b/events/CommandHandler.js @@ -29,8 +29,7 @@ class CommandHandler extends BaseEvent { data.memberData = memberData; } - if (interaction.isAutocomplete()) - return await command.autocompleteRun(client, interaction); + if (interaction.isAutocomplete()) return await command.autocompleteRun(client, interaction); if (interaction.type !== InteractionType.ApplicationCommand && !interaction.isCommand()) return; if (command.ownerOnly && interaction.user.id !== client.config.owner.id) return interaction.error("misc:OWNER_ONLY", null, { ephemeral: true }); diff --git a/events/Guild/guildBanAdd.js b/events/Guild/guildBanAdd.js index 269c4d24..77139c9d 100644 --- a/events/Guild/guildBanAdd.js +++ b/events/Guild/guildBanAdd.js @@ -17,11 +17,12 @@ class guildBanAdd extends BaseEvent { async execute(client, ban) { const embed = new EmbedBuilder() .setAuthor({ - name: client.user.username, + name: client.user.getUsername(), iconURL: ban.guild.iconURL(), }) - .setColor("#FF0000") - .setDescription(`Вы были забанены на **${ban.guild.name}** по причине **${ban.reason || "Не указана"}**`); + .setColor(client.config.embed.color) + .setFooter({ text: client.config.embed.footer }) + .setDescription(`You were banned from **${ban.guild.name}**!\nReason: **${ban.reason || "Not specified"}**`); ban.user.send({ embeds: [embed], diff --git a/events/Guild/guildCreate.js b/events/Guild/guildCreate.js index f96c7744..8cd819e4 100644 --- a/events/Guild/guildCreate.js +++ b/events/Guild/guildCreate.js @@ -54,7 +54,8 @@ class GuildCreate extends BaseEvent { name: guild.name, iconURL: guild.iconURL(), }) - .setColor("#32CD32") + .setColor(client.config.embed.color) + .setFooter({ text: client.config.embed.footer }) .setDescription(`Зашёл на сервер **${guild.name}**. На нём **${users}** ${client.functions.getNoun(users, client.translate("misc:NOUNS:USERS:1"), client.translate("misc:NOUNS:USERS:2"), client.translate("misc:NOUNS:USERS:5"))} и **${bots}** ${client.functions.getNoun(bots, client.translate("misc:NOUNS:BOTS:1"), client.translate("misc:NOUNS:BOTS:2"), client.translate("misc:NOUNS:BOTS:5"))}`); client.channels.cache.get(client.config.support.logs).send({ embeds: [embed], diff --git a/events/Guild/guildDelete.js b/events/Guild/guildDelete.js index 0ac76e1d..bc1165cc 100644 --- a/events/Guild/guildDelete.js +++ b/events/Guild/guildDelete.js @@ -20,7 +20,8 @@ class GuildDelete extends BaseEvent { name: guild.name, iconURL: guild.iconURL(), }) - .setColor("#FF0000") + .setColor(client.config.embed.color) + .setFooter({ text: client.config.embed.footer }) .setDescription(`Вышел с сервера **${guild.name}**.`); client.channels.cache.get(client.config.support.logs).send({ embeds: [embed], diff --git a/events/Guild/guildMemberAdd.js b/events/Guild/guildMemberAdd.js index aafc425b..e2945b55 100644 --- a/events/Guild/guildMemberAdd.js +++ b/events/Guild/guildMemberAdd.js @@ -28,12 +28,12 @@ class GuildMemberAdd extends BaseEvent { * @param {import("discord.js").GuildMember} member */ async execute(client, member) { - if (member.guild && member.guild.id === "568120814776614924") return; + if (member.guild && member.guildId === "568120814776614924") return; await member.guild.members.fetch(); const guildData = await client.findOrCreateGuild({ - id: member.guild.id, + id: member.guildId, }); if (guildData.plugins.autorole.enabled) member.roles.add(guildData.plugins.autorole.role); diff --git a/events/Guild/guildMemberRemove.js b/events/Guild/guildMemberRemove.js index fd5f59e8..67d5b570 100644 --- a/events/Guild/guildMemberRemove.js +++ b/events/Guild/guildMemberRemove.js @@ -28,12 +28,12 @@ class GuildMemberRemove extends BaseEvent { * @param {import("discord.js").GuildMember} member */ async execute(client, member) { - if (member.guild && member.guild.id === "568120814776614924") return; + if (member.guild && member.guildId === "568120814776614924") return; await member.guild.members.fetch(); const guildData = await client.findOrCreateGuild({ - id: member.guild.id, + id: member.guildId, }); if (guildData.plugins.goodbye.enabled) { diff --git a/events/Guild/guildMemberUpdate.js b/events/Guild/guildMemberUpdate.js index d0a990ef..7c6b30be 100644 --- a/events/Guild/guildMemberUpdate.js +++ b/events/Guild/guildMemberUpdate.js @@ -15,8 +15,8 @@ class GuildMemberUpdate extends BaseEvent { * @param {import("discord.js").GuildMember} newMember */ async execute(client, oldMember, newMember) { - if (oldMember.guild && oldMember.guild.id === "568120814776614924") return; - if (oldMember.guild.id !== client.config.support.id) return; + if (oldMember.guild && oldMember.guildId === "568120814776614924") return; + if (oldMember.guildId !== client.config.support.id) return; if (oldMember.roles.cache.some(r => r.id === "940149470975365191")) return; if (newMember?.roles.cache.some(r => r.id === "940149470975365191")) { diff --git a/events/MessageHandler.js b/events/MessageHandler.js index 3a633438..fc7378a9 100644 --- a/events/MessageHandler.js +++ b/events/MessageHandler.js @@ -105,7 +105,9 @@ class MessageCreate extends BaseEvent { const afkReason = data.userData.afk; if (afkReason) { data.userData.afk = null; + data.userData.markModified("afk"); await data.userData.save(); + message.replyT("general/afk:DELETED", { user: message.author.username, }, { mention: true }); @@ -154,6 +156,9 @@ async function updateXp(client, msg, memberData) { }, { mention: false }); } else memberData.exp = parseInt(newXp, 10); + memberData.markModified("exp"); + memberData.markModified("level"); + await memberData.save(); } diff --git a/events/Monitoring/messageUpdate.js b/events/Monitoring/messageUpdate.js new file mode 100644 index 00000000..4d865e69 --- /dev/null +++ b/events/Monitoring/messageUpdate.js @@ -0,0 +1,45 @@ +const { EmbedBuilder } = require("discord.js"), + BaseEvent = require("../../base/BaseEvent"); + +class messageUpdate extends BaseEvent { + constructor() { + super({ + name: "messageUpdate", + once: false, + }); + } + + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").Message} oldMessage + * @param {import("discord.js").Message} newMessage + */ + async execute(client, oldMessage, newMessage) { + if (oldMessage.guild && oldMessage.guildId === "568120814776614924") return; + if (oldMessage.author.bot) return; + + if (oldMessage.content === newMessage.content) return; + + const guildData = await client.findOrCreateGuild({ id: oldMessage.guildId }); + + if (guildData.plugins.monitoring.messageUpdate) { + const embed = new EmbedBuilder() + .setAuthor({ + name: newMessage.author.getUsername(), + iconURL: newMessage.author.displayAvatarURL(), + }) + .setColor(client.config.embed.color) + .setFooter({ text: client.config.embed.footer }) + .setTitle(`${newMessage.author.getUsername()} edited a message!`) + .setDescription(`Old Message: \`\`\`${oldMessage.content}\`\`\`\nNew Message: \`\`\`${newMessage.content}\`\`\`\nJump to message: ${newMessage.url}`); + + newMessage.guild.channels.cache.get(guildData.plugins.monitoring.messageUpdate).send({ + embeds: [embed], + }); + } + + } +} + +module.exports = messageUpdate; \ No newline at end of file diff --git a/helpers/checkReminds.js b/helpers/checkReminds.js index e2daf503..5bf50f94 100644 --- a/helpers/checkReminds.js +++ b/helpers/checkReminds.js @@ -48,6 +48,7 @@ module.exports.init = function (client) { }); }); user.reminds = user.reminds.filter(r => r.sendAt >= dateNow); + user.markModified("reminds"); user.save(); if (user.reminds.length === 0) client.databaseCache.usersReminds.delete(user.id); diff --git a/helpers/cleanup.js b/helpers/cleanup.js index 53b10017..6444811d 100644 --- a/helpers/cleanup.js +++ b/helpers/cleanup.js @@ -29,6 +29,8 @@ module.exports.init = async function (client) { if (transaction.date < timestamp) { const index = transactions.indexOf(transaction); transactions.splice(index, 1); + + member.markModified("transactions"); await member.save(); } } diff --git a/languages/en-US/administration/config.json b/languages/en-US/administration/config.json index 1d28678a..538de750 100644 --- a/languages/en-US/administration/config.json +++ b/languages/en-US/administration/config.json @@ -3,33 +3,30 @@ "USAGE": "list\nset [setting] (state) (#channel)", "EXAMPLES": "config list\nconfig set setting:reports state:True channel:#reports", + "SPECIAL_CHANNELS": "Special Channels", "BIRTHDAYS": "Birthday Greetings", "MODLOGS": "Moderation Logs", "REPORTS": "Reports", "SUGGESTIONS": "Suggestions", - "BIRTHDAYS_LIST": "Birthday Greetings: {{channel}}", - "MODLOGS_LIST": "Moderation Logs: {{channel}}", - "NEWS_LIST": "Bot News: {{channel}}", - "REPORTS_LIST": "Reports: {{channel}}", - "SUGGESTIONS_LIST": "Suggestions: {{channel}}", + "MONITORING_CHANNELS": "Monitoring Channels", + "MESSAGEUPDATE": "Message Update Logs", - "AUTOMOD_CONTENT": "Automoderation is enabled.\nIgnored channels: {{channels}}", "AUTOMOD_TITLE": "Automoderation", + "AUTOMOD_CONTENT": "Automoderation is enabled.\nIgnored channels: {{channels}}", "AUTOROLE_TITLE": "Automatic Role Assignment", "AUTO_SANCTIONS": "Automatic Sanctions", "BAN_CONTENT": "Ban: After **{{count}}** warnings", "BAN_NOT_DEFINED": "Ban: Not set", - "DASHBOARD_CONTENT": "Click here to go to the dashboard", "DASHBOARD_TITLE": "Modify Settings", - "GOODBYE_CONTENT": "Channel: {{channel}}\nCard: {{withImage}}", + "DASHBOARD_CONTENT": "Click here to go to the dashboard", "GOODBYE_TITLE": "Farewell", + "GOODBYE_CONTENT": "Channel: {{channel}}\nCard: {{withImage}}", "KICK_CONTENT": "Kick: After **{{count}}** warnings", "KICK_NOT_DEFINED": "Kick: Not set", "LIST": "Display server settings", "SET": "Modify server settings", "SETTING": "Settings", - "SPECIAL_CHANNELS": "Special Channels", - "WELCOME_CONTENT": "Channel: {{channel}}\nCard: {{withImage}}", - "WELCOME_TITLE": "Welcome" + "WELCOME_TITLE": "Welcome", + "WELCOME_CONTENT": "Channel: {{channel}}\nCard: {{withImage}}" } \ No newline at end of file diff --git a/languages/ru-RU/administration/config.json b/languages/ru-RU/administration/config.json index 83201229..0c17c27f 100644 --- a/languages/ru-RU/administration/config.json +++ b/languages/ru-RU/administration/config.json @@ -3,33 +3,30 @@ "USAGE": "list\nset [setting] (state) (#channel)", "EXAMPLES": "config list\nconfig set setting:reports state:True channel:#reports", + "SPECIAL_CHANNELS": "Специальные каналы", "BIRTHDAYS": "Поздравления с днём рождения", "MODLOGS": "Логи модерации", "REPORTS": "Жалобы", "SUGGESTIONS": "Предложения", - "BIRTHDAYS_LIST": "Поздравления с днём рождения: {{channel}}", - "MODLOGS_LIST": "Логи модерации: {{channel}}", - "NEWS_LIST": "Новости бота: {{channel}}", - "REPORTS_LIST": "Жалобы: {{channel}}", - "SUGGESTIONS_LIST": "Предложения: {{channel}}", + "MONITORING_CHANNELS": "Каналы мониторинга", + "MESSAGEUPDATE": "Логи изменения сообщений", - "AUTOMOD_CONTENT": "Автомодерация включена.\nИгнорируемые каналы: {{channels}}", "AUTOMOD_TITLE": "Автомодерация", + "AUTOMOD_CONTENT": "Автомодерация включена.\nИгнорируемые каналы: {{channels}}", "AUTOROLE_TITLE": "Автоназначение роли при входе", "AUTO_SANCTIONS": "Автоматические наказания", "BAN_CONTENT": "Бан: После **{{count}}** предупреждений", "BAN_NOT_DEFINED": "Бан: Не назначено", - "DASHBOARD_CONTENT": "Нажмите сюда, чтобы перейти в панель управления", "DASHBOARD_TITLE": "Изменить настройки", - "GOODBYE_CONTENT": "Канал: {{channel}}\nКарточка: {{withImage}}", + "DASHBOARD_CONTENT": "Нажмите сюда, чтобы перейти в панель управления", "GOODBYE_TITLE": "Прощание", + "GOODBYE_CONTENT": "Канал: {{channel}}\nКарточка: {{withImage}}", "KICK_CONTENT": "Кик: После **{{count}}** предупреждений", "KICK_NOT_DEFINED": "Кик: Не назначено", "LIST": "Показать настройки сервера", "SET": "Изменить настройки сервера", "SETTING": "Параметр", - "SPECIAL_CHANNELS": "Специальные каналы", - "WELCOME_CONTENT": "Канал: {{channel}}\nКарточка: {{withImage}}", - "WELCOME_TITLE": "Приветствие" + "WELCOME_TITLE": "Приветствие", + "WELCOME_CONTENT": "Канал: {{channel}}\nКарточка: {{withImage}}" } \ No newline at end of file diff --git a/languages/uk-UA/administration/config.json b/languages/uk-UA/administration/config.json index add73bae..10ed1d22 100644 --- a/languages/uk-UA/administration/config.json +++ b/languages/uk-UA/administration/config.json @@ -2,23 +2,31 @@ "DESCRIPTION": "Показати налаштування сервера", "USAGE": "", "EXAMPLES": "config", - "AUTOROLE_TITLE": "Автопризначення ролі при вході", - "WELCOME_TITLE": "Привітання", - "WELCOME_CONTENT": "Канал: {{channel}}\nКартка: {{withImage}}", - "GOODBYE_TITLE": "Прощання", - "GOODBYE_CONTENT": "Канал: {{channel}}\nКартка: {{withImage}}", + "SPECIAL_CHANNELS": "Спеціальні канали", - "MODLOGS": "Логи модерації: {{channel}}", - "BIRTHDAYS": "Привітання з днем ​​народження: {{channel}}", - "SUGGESTIONS": "Пропозиції: {{channel}}", - "REPORTS": "Скарги: {{channel}}", + "BIRTHDAYS": "Привітання з днем ​​народження", + "MODLOGS": "Логи модерації", + "REPORTS": "Скарги", + "SUGGESTIONS": "Пропозиції", + + "MONITORING_CHANNELS": "Каналы мониторинга", + "MESSAGEUPDATE": "Логи изменения сообщений", + "AUTOMOD_TITLE": "Автомодерація", "AUTOMOD_CONTENT": "Автомодерація включена.\nІгноровані канали: {{channels}}", + "AUTOROLE_TITLE": "Автопризначення ролі при вході", "AUTO_SANCTIONS": "Автоматичні покарання", - "KICK_CONTENT": "Кік: Після **{{count}}** попереджень", - "KICK_NOT_DEFINED": "Кік: Не призначено", "BAN_CONTENT": "Бан: Після **{{count}}** попереджень", "BAN_NOT_DEFINED": "Бан: Не призначено", "DASHBOARD_TITLE": "Змінити налаштування", - "DASHBOARD_CONTENT": "Натисніть сюди, щоб перейти до панелі керування" + "DASHBOARD_CONTENT": "Натисніть сюди, щоб перейти до панелі керування", + "GOODBYE_TITLE": "Прощання", + "GOODBYE_CONTENT": "Канал: {{channel}}\nКартка: {{withImage}}", + "KICK_CONTENT": "Кік: Після **{{count}}** попереджень", + "KICK_NOT_DEFINED": "Кік: Не призначено", + "LIST": "Показати налаштування серверу", + "SET": "Змінити налаштування серверу ", + "SETTING": "Параметр", + "WELCOME_TITLE": "Привітання", + "WELCOME_CONTENT": "Канал: {{channel}}\nКартка: {{withImage}}" } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index da439d04..374f1e61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jaba", - "version": "4.3.0", + "version": "4.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "jaba", - "version": "4.3.0", + "version": "4.3.1", "license": "ISC", "dependencies": { "@discord-player/extractor": "^4.3.1", diff --git a/package.json b/package.json index de8b0b21..554eb011 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jaba", - "version": "4.3.0", + "version": "4.3.1", "description": "My Discord Bot", "main": "index.js", "private": true, diff --git a/scripts/create-db-indexes.js b/scripts/create-db-indexes.js deleted file mode 100644 index dedd3d52..00000000 --- a/scripts/create-db-indexes.js +++ /dev/null @@ -1,61 +0,0 @@ -const chalk = require("chalk"); -console.log(chalk.blue("Creating database indexes...\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, { - useNewUrlParser: true, - 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 members = db.collection("members"); - const users = db.collection("users"); - - console.log(chalk.yellow("Creating guilds index...")); - - await guilds.createIndex({ - id: 1, - }); - - console.log(chalk.green("Guilds index created.")); - - console.log(chalk.yellow("Creating members index...")); - - await members.createIndex({ - guildID: 1, - id: -1, - }); - - console.log(chalk.green("Members index created.")); - - console.log(chalk.yellow("Creating users index...")); - - await users.createIndex({ - id: 1, - }); - - console.log(chalk.green("Users index created.")); - - console.log(chalk.blue("\n\nIndexes created.")); - - process.exit(0); -}).catch(() => { - console.log(chalk.red("Couldn't connect to mongoDB database...")); - - process.exit(1); -}); \ No newline at end of file