diff --git a/commands/util/command-leaderboard-import.js b/commands/util/command-leaderboard-import.js index 22e087f3..2dbc0f52 100644 --- a/commands/util/command-leaderboard-import.js +++ b/commands/util/command-leaderboard-import.js @@ -18,13 +18,21 @@ module.exports = class CommandLeaderboardImportCommand extends Command { description: 'Imports a command leaderboard JSON file.', details: 'Only the bot owner(s) may use this command.', ownerOnly: true, - guarded: true + guarded: true, + args: [ + { + key: 'add', + prompt: 'Do you want to add the values to the existing ones?', + type: 'boolean', + default: false + } + ] }); } - run(msg) { + run(msg, { add }) { try { - const results = this.client.importCommandLeaderboard(); + const results = this.client.importCommandLeaderboard(add); if (!results) return msg.reply('The JSON file provided is invalid.'); return msg.say('Successfully imported command leaderboard.'); } catch (err) { diff --git a/structures/Client.js b/structures/Client.js index 426f7899..9a1cafb5 100644 --- a/structures/Client.js +++ b/structures/Client.js @@ -90,7 +90,7 @@ module.exports = class XiaoClient extends CommandoClient { return buf; } - importCommandLeaderboard() { + importCommandLeaderboard(add = false) { const read = fs.readFileSync(path.join(__dirname, '..', 'command-leaderboard.json'), { encoding: 'utf8' }); @@ -100,7 +100,8 @@ module.exports = class XiaoClient extends CommandoClient { if (typeof value !== 'number') continue; const found = this.registry.commands.get(id); if (!found || found.uses === undefined) continue; - found.uses = value; + if (add) found.uses += value; + else found.uses = value; } return file; }