forked from Galactic/galactic-bot
74 lines
2.1 KiB
JavaScript
74 lines
2.1 KiB
JavaScript
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"
|
|
],
|
|
arguments: [
|
|
{
|
|
name: 'silent',
|
|
type: 'BOOLEAN',
|
|
types: ['FLAG'],
|
|
default: true
|
|
}
|
|
],
|
|
guildOnly: true,
|
|
showUsage: true,
|
|
throttling: {
|
|
usages: 2,
|
|
duration: 10
|
|
},
|
|
archivable: false
|
|
});
|
|
}
|
|
|
|
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, (c) => c.type === 'text');
|
|
|
|
if(parsed.length === 0) {
|
|
parsed = [ message.channel ];
|
|
}
|
|
|
|
const [firstArgument] = parameters;
|
|
const [, match ] = (/(\w{0,});?/ui).exec(firstArgument);
|
|
|
|
let reason = parameters;
|
|
let time = this.client.resolver.resolveTime(match);
|
|
|
|
if(!time) time = 0;
|
|
else reason = reason.slice(1);
|
|
|
|
if(time !== 0) {
|
|
if(time < 60 || time > 2629801) {
|
|
return message.respond('C_LOCKDOWN_DURATIONEXCEPTION');
|
|
}
|
|
}
|
|
|
|
return this.client.moderationManager
|
|
.handleInfraction(Lockdown, message, {
|
|
targets: parsed,
|
|
duration: time,
|
|
reason: reason.join(' ')
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = LockdownCommand; |