From 5f646f33212e5e13ba6694bc8588f397bedcbb2c Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 23 Jul 2022 20:44:03 +0300 Subject: [PATCH] import thing --- .../commands/administration/Import.js | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/structure/components/commands/administration/Import.js b/src/structure/components/commands/administration/Import.js index 1e6b213..cd1586c 100644 --- a/src/structure/components/commands/administration/Import.js +++ b/src/structure/components/commands/administration/Import.js @@ -4,14 +4,17 @@ const { SlashCommand } = require("../../../interfaces"); const dbs = { '2': process.env.NODE_ENV === 'development' ? 'navybot' : 'galacticbot', - '3': 'newgbot' + 'qa': 'galactic' }; -const { MONGODB_HOST, MONGODB_USERNAME, MONGODB_PASSWORD, MONGODB_V2_HOST } = process.env; +const { MONGODB_QA_HOST, MONGODB_USERNAME, MONGODB_PASSWORD, MONGODB_V2_HOST } = process.env; class ImportCommand extends SlashCommand { constructor(client) { + const importChoices = [{ name: 'v2', value: '2' }]; + if (process.env.NODE_ENV === 'production') importChoices.push({ name: 'qa', value: 'qa' }); + super(client, { name: 'import', description: 'Import old settings & modlogs', @@ -24,10 +27,7 @@ class ImportCommand extends SlashCommand { options: [{ name: 'version', description: 'Which version do you want to import from', - choices: [ - { name: 'v2', value: '2' }, - { name: 'v3', value: '3' } - ] + choices: importChoices }] }, { name: 'modlogs', @@ -35,10 +35,7 @@ class ImportCommand extends SlashCommand { options: [{ name: 'version', description: 'Which version do you want to import from', - choices: [ - { name: 'v2', value: '2' }, - { name: 'v3', value: '3' } - ] + choices: importChoices }, { name: 'overwrite', description: 'Whether any existing logs should be overwritten by the imports. By default new ones are bumped', @@ -54,7 +51,7 @@ class ImportCommand extends SlashCommand { const data = await guild.fetchData(); if (!data._imported) data._imported = {}; if (data._imported[subcommand.name]) return { emoji: 'failure', index: 'COMMAND_IMPORT_IMPORTED', params: { thing: Util.capitalise(subcommand.name) } }; - version = version?.value || '3'; + version = version?.value || '2'; await invoker.reply({ index: 'COMMAND_IMPORT_WORKING', emoji: 'loading' }); const result = await this[subcommand.name](guild, version, overwrite?.value); @@ -72,10 +69,10 @@ class ImportCommand extends SlashCommand { async modlogs(guild, version, overwrite = false) { const migrator = new InfractionMigrator(this.client, guild, { - host: version === '2' ? MONGODB_V2_HOST : MONGODB_HOST, + host: version === '2' ? MONGODB_V2_HOST : MONGODB_QA_HOST, username: version === '2' ? null : MONGODB_USERNAME, password: MONGODB_PASSWORD, - database: dbs[version], // Default to v3 + database: dbs[version], version }); @@ -114,7 +111,7 @@ class ImportCommand extends SlashCommand { async settings(guild, version) { // const { MONGODB_HOST, MONGODB_USERNAME, MONGODB_PASSWORD } = process.env; const migrator = new SettingsMigrator(this.client, guild, { - host: version === '2' ? MONGODB_V2_HOST : MONGODB_HOST, + host: version === '2' ? MONGODB_V2_HOST : MONGODB_QA_HOST, username: version === '2' ? null : MONGODB_USERNAME, password: MONGODB_PASSWORD, database: dbs[version], // Default to v3