modlogs import
This commit is contained in:
parent
3786cc2b40
commit
b38206a795
@ -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' };
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user