From a3fb059031d8fed03a1ff96b45f8f991b8ccea22 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Mon, 25 Apr 2022 14:08:03 +0300 Subject: [PATCH] import command --- .../commands/administration/Import.js | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/structure/components/commands/administration/Import.js diff --git a/src/structure/components/commands/administration/Import.js b/src/structure/components/commands/administration/Import.js new file mode 100644 index 0000000..6ac9b46 --- /dev/null +++ b/src/structure/components/commands/administration/Import.js @@ -0,0 +1,60 @@ +const SettingsMigrator = require("../../../../utilities/SettingsMigrator"); +const { SlashCommand } = require("../../../interfaces"); + +const dbs = { + '2': 'galacticbot', + '3': 'newgbot' +}; + +class ImportCommand extends SlashCommand { + + constructor(client) { + + super(client, { + name: 'import', + description: 'Import old settings & modlogs', + module: 'administration', + guildOnly: true, + memberPermissions: ['ADMINISTRATOR'], + options: [{ + name: ['settings', 'modlogs'], + type: 'SUB_COMMAND', + options: [{ + name: 'version', + description: 'Which version do you want to import', + choices: [ + { name: 'v2', value: '2' }, + { name: 'v3', value: '3' } + ] + }] + }] + }); + + } + + async execute(invoker, { version }) { + const { subcommand, guild } = invoker; + const settings = await guild.settings(); + if (settings._imported); + console.log(subcommand); + version = version?.value || '3'; + + // TODO split into settings and modlogs + + const { MONGODB_HOST, MONGODB_USERNAME, MONGODB_PASSWORD } = process.env; + const migrator = new SettingsMigrator(guild, { + host: MONGODB_HOST, + username: MONGODB_USERNAME, + password: MONGODB_PASSWORD, + database: dbs[version], // Default to v3 + version + }); + await migrator.connect(); + const imported = await migrator.migrate(); + console.log(imported); + console.log(settings); + } + +} + +module.exports = ImportCommand; \ No newline at end of file