import command

This commit is contained in:
Erik 2022-04-25 14:08:03 +03:00
parent 15c432d739
commit a3fb059031
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -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;