const { Command } = require('../../../../interfaces/'); const { Unlockdown } = require('../../../../moderation/infractions/'); class UnlockdownCommand extends Command { constructor(client) { super(client, { name: 'unlockdown', module: 'moderation', usage: "[channel..] [duration] [reason..]", aliases: [ 'lock' ], clientPermissions: ['MANAGE_CHANNELS'], memberPermissions: ['MANAGE_CHANNELS'], examples: [ "#general #off-topic raid", "" ], guildOnly: true, showUsage: true, throttling: { usages: 2, duration: 10 } }); } async execute(message, { qParams }) { let { parsed, parameters } = await this.client.resolver.infinite(qParams, [ //eslint-disable-line prefer-const this.client.resolver.resolveChannel.bind(this.client.resolver) ], true, message.guild); if(parsed.length === 0) { parsed = [ message.channel ]; } if(parameters.length === 0) return message.respond(message.format('C_PRUNE_INTEGERINVALID'), { emoji: 'failure' }); let int = parseInt(parameters[0]); if(Number.isNaN(int)) { return message.respond(message.format('C_PRUNE_INTEGERINVALID'), { emoji: 'failure' }); } if(int < 1 || int > 300) { return message.respond(message.format('C_PRUNE_INTEGEREXCEPTION'), { emoji: 'failure' }); } if(int % 100 > 0) int++; //Increase amount by one (to delete command message) ONLY IF indivisible by 100, this is to save a message fetch call. const reason = parameters.slice(1).join(' '); return this.client.moderationManager .handleInfraction(Unlockdown, message, { targets: parsed, data: { amount: int }, reason }); } } module.exports = UnlockdownCommand;