2021-05-10 22:09:03 +02:00
|
|
|
const { Command } = require('../../../../interfaces/');
|
|
|
|
const { Lockdown } = require('../../../../moderation/infractions/');
|
|
|
|
|
|
|
|
class LockdownCommand extends Command {
|
|
|
|
|
|
|
|
constructor(client) {
|
|
|
|
|
|
|
|
super(client, {
|
|
|
|
name: 'lockdown',
|
|
|
|
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
|
2021-06-11 03:08:31 +02:00
|
|
|
},
|
|
|
|
archivable: false
|
2021-05-10 22:09:03 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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(Lockdown, message, {
|
|
|
|
targets: parsed,
|
|
|
|
data: {
|
|
|
|
amount: int
|
|
|
|
},
|
|
|
|
reason
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = LockdownCommand;
|