galactic-bot/structure/client/components/commands/moderation/Softban.js
2020-07-16 00:54:39 -07:00

96 lines
3.0 KiB
JavaScript

const { Command } = require('../../../../interfaces/');
const { Softban } = require('../../../../moderation/infractions/');
class SoftbanCommand extends Command {
constructor(client) {
super(client, {
name: 'softban',
module: 'moderation',
usage: "<member..> [reason]",
clientPermissions: ['BAN_MEMBERS'],
memberPermissions: ['KICK_MEMBERS'],
examples: [
"@nolan#2887 @Navy.gif#1998 spamming the chat"
],
keepQuotes: true,
arguments: [
{
name: 'points',
aliases: ['point', 'modpoints', 'modpoint', 'pts', 'pt'],
type: 'INTEGER',
types: ['VERBAL', 'FLAG'],
usage: '<amount>',
default: (guild) => {
return guild._settings.moderationPoints.points.KICK;
},
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.KICK;
}
},
{
name: 'days',
aliases: ['day'],
type: 'INTEGER',
types: ['FLAG'],
usage: '<days>',
default: 1,
min: 1, max: 7,
ignoreInvalid: true
},
{
name: 'force',
type: 'BOOLEAN',
types: ['FLAG'],
default: true
},
{
name: 'silent',
type: 'BOOLEAN',
types: ['FLAG'],
default: true
}
],
guildOnly: true,
showUsage: true
});
this.client = client;
}
async execute(message, { params }) {
const { parsed, parameters } = await this.client.resolver.infinite(params, [
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_KICK_MISSINGMEMBERS'), {
emoji: 'failure'
});
}
return this.client.moderationManager
.handleInfraction(Softban, message, {
targets: parsed,
reason: parameters.join(' ')
});
}
}
module.exports = SoftbanCommand;