From b38206a795ed661af55151837542e04dd96c4259 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 18 Jun 2022 14:01:37 +0300 Subject: [PATCH] modlogs import --- .../components/commands/administration/Import.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/structure/components/commands/administration/Import.js b/src/structure/components/commands/administration/Import.js index 06d757b..2b50c1e 100644 --- a/src/structure/components/commands/administration/Import.js +++ b/src/structure/components/commands/administration/Import.js @@ -89,11 +89,12 @@ class ImportCommand extends SlashCommand { return { index: 'COMMAND_IMPORT_ERROR', params: { message: err.message }, emoji: 'failure' }; } await migrator.end(); - console.log(imported); + this.client.logger(`Imported ${imported.length} infractions in ${guild.name}`); if (overwrite) { // Overwrite any existing logs with the imported ones await this.client.mongodb.infractions.deleteMany({ guild: guild.id }); await this.client.mongodb.infractions.insertMany(imported); + guild._data.caseId = imported[imported.length-1].case; } else { // Bump existing logs by the highest case id from imported logs const highestOldId = imported[imported.length - 1]; const existingLogs = await this.client.mongodb.infractions.find({ guild: guild.id }); @@ -101,12 +102,11 @@ class ImportCommand extends SlashCommand { log.case += highestOldId; await this.client.mongodb.infractions.updateOne({ _id: log._id }, { case: log.case }); } - guild._settings.caseId += highestOldId; - await guild.updateSettings({ caseId: guild._settings.caseId }); + guild._data.caseId += highestOldId; } - - return { content: 'blah' }; + await guild.updateData({ caseId: guild._data.caseId }); + return { index: 'COMMAND_INFRACTIONS_IMPORT_SUCCESS', params: { cases: imported.length } }; } @@ -148,8 +148,11 @@ class ImportCommand extends SlashCommand { await this.client.storageManager.mongodb.permissions.updateOne({ guildId: guild.id }, permissions); } + const { premium } = imported.settings; + delete imported.settings.premium; + await guild.updateData({ premium }); await guild.updateSettings(imported.settings); - return { index: 'COMMAND_IMPORT_SUCCESS', emoji: 'success' }; + return { index: 'COMMAND_SETTINGS_IMPORT_SUCCESS', emoji: 'success' }; } }