forked from Galactic/galactic-bot
122 lines
3.8 KiB
JavaScript
122 lines
3.8 KiB
JavaScript
const { Command } = require('../../../../interfaces/');
|
|
const { Ban } = require('../../../../moderation/infractions/');
|
|
|
|
class BanCommand extends Command {
|
|
|
|
constructor(client) {
|
|
|
|
super(client, {
|
|
name: 'ban',
|
|
module: 'moderation',
|
|
usage: "<member..> [duration] [reason]",
|
|
clientPermissions: ['BAN_MEMBERS'],
|
|
memberPermissions: ['BAN_MEMBERS'],
|
|
aliases: [
|
|
'tempban',
|
|
'hardban'
|
|
],
|
|
examples: [
|
|
"@nolan#2887 @Navy.gif#1998 24h raiding the server"
|
|
],
|
|
arguments: [
|
|
{
|
|
name: 'points',
|
|
aliases: ['point', 'modpoints', 'modpoint', 'pts', 'pt'],
|
|
type: 'INTEGER',
|
|
types: ['VERBAL', 'FLAG'],
|
|
usage: '<amount>',
|
|
default: (guild) => {
|
|
return guild._settings.moderationPoints.points.BAN;
|
|
},
|
|
min: 0, max: 100,
|
|
ignoreInvalid: true,
|
|
required: true
|
|
},
|
|
{
|
|
name: 'expiration',
|
|
aliases: ['expire', 'expires', 'expirations'],
|
|
type: 'TIME',
|
|
types: ['FLAG'],
|
|
usage: '<time>',
|
|
default: (guild) => {
|
|
return guild._settings.moderationPoints.expirations.BAN;
|
|
}
|
|
},
|
|
{
|
|
name: 'force',
|
|
type: 'BOOLEAN',
|
|
types: ['FLAG'],
|
|
default: true
|
|
},
|
|
{
|
|
name: 'days',
|
|
aliases: ['day'],
|
|
type: 'INTEGER',
|
|
types: ['FLAG'],
|
|
usage: '<days>',
|
|
default: 1,
|
|
min: 1, max: 7,
|
|
ignoreInvalid: true
|
|
},
|
|
{
|
|
name: 'silent',
|
|
type: 'BOOLEAN',
|
|
types: ['FLAG'],
|
|
default: true
|
|
}
|
|
],
|
|
guildOnly: true,
|
|
showUsage: true,
|
|
throttling: {
|
|
usages: 2,
|
|
duration: 5
|
|
}
|
|
});
|
|
|
|
this.client = client;
|
|
|
|
}
|
|
|
|
async execute(message, { qParams }) {
|
|
|
|
const { parsed, parameters } = await this.client.resolver.infinite(qParams, [
|
|
this.client.resolver.resolveMember.bind(this.client.resolver),
|
|
this.client.resolver.resolveUser.bind(this.client.resolver)
|
|
], true, message.guild);
|
|
|
|
if(parsed.length === 0) {
|
|
return message.respond(message.format('C_BAN_MISSINGMEMBERS'), {
|
|
emoji: 'failure'
|
|
});
|
|
}
|
|
|
|
const [firstArgument] = parameters;
|
|
const [, match ] = (/(\w{0,});?/ui).exec(firstArgument);
|
|
|
|
let reason = parameters;
|
|
let time = this.client.resolver.resolveTime(match);
|
|
if(!time) {
|
|
if(message._caller === 'tempban') return message.respond(message.format('C_BAN_DURATIONREQUIRED'), { emoji: 'failure' });
|
|
time = 0;
|
|
} else {
|
|
reason = reason.slice(1);
|
|
}
|
|
|
|
if(time !== 0) {
|
|
if(time < 60 || time > 7889401) { // approx. over 3 months (according to resolveTime)
|
|
return message.respond(message.format('C_BAN_DURATIONEXCEPTION'), { emoji: 'failure' });
|
|
}
|
|
}
|
|
|
|
return this.client.moderationManager
|
|
.handleInfraction(Ban, message, {
|
|
targets: parsed,
|
|
duration: time,
|
|
reason: reason.join(' ')
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = BanCommand; |