import command
This commit is contained in:
parent
15c432d739
commit
a3fb059031
60
src/structure/components/commands/administration/Import.js
Normal file
60
src/structure/components/commands/administration/Import.js
Normal 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;
|
Loading…
Reference in New Issue
Block a user