184 lines
5.5 KiB
JavaScript
184 lines
5.5 KiB
JavaScript
|
const { Command } = require('../../../../interfaces/');
|
||
|
const { Prune } = require('../../../../moderation/infractions/');
|
||
|
|
||
|
class PruneCommand extends Command {
|
||
|
|
||
|
constructor(client) {
|
||
|
|
||
|
super(client, {
|
||
|
name: 'prune',
|
||
|
module: 'moderation',
|
||
|
usage: "[channel..] <amount> [reason]",
|
||
|
aliases: [
|
||
|
'purge'
|
||
|
],
|
||
|
clientPermissions: ['MANAGE_MESSAGES'],
|
||
|
memberPermissions: ['MANAGE_MESSAGES'],
|
||
|
examples: [
|
||
|
"50 -u @nolan#2887 @Navy#1998 they were spamming",
|
||
|
"10 bot spam -b"
|
||
|
],
|
||
|
keepQuotes: true,
|
||
|
arguments: [
|
||
|
{
|
||
|
name: 'users',
|
||
|
aliases: [
|
||
|
'user'
|
||
|
],
|
||
|
usage: '<member..>',
|
||
|
type: 'MEMBER',
|
||
|
types: ['FLAG'],
|
||
|
required: true,
|
||
|
infinite: true
|
||
|
},
|
||
|
{
|
||
|
name: 'bots',
|
||
|
aliases: ['bot', 'robots', 'robot'],
|
||
|
type: 'BOOLEAN',
|
||
|
types: ['FLAG'],
|
||
|
default: true
|
||
|
},
|
||
|
{
|
||
|
name: 'text',
|
||
|
aliases: [
|
||
|
'contains'
|
||
|
],
|
||
|
usage: '<text>',
|
||
|
type: 'STRING',
|
||
|
types: ['FLAG'],
|
||
|
required: true
|
||
|
},
|
||
|
{
|
||
|
name: 'startswith',
|
||
|
aliases: [
|
||
|
'starts',
|
||
|
'begins'
|
||
|
],
|
||
|
usage: '<text>',
|
||
|
type: 'STRING',
|
||
|
types: ['FLAG'],
|
||
|
required: true
|
||
|
},
|
||
|
{
|
||
|
name: 'endswith',
|
||
|
aliases: [
|
||
|
'ends'
|
||
|
],
|
||
|
usage: '<text>',
|
||
|
type: 'STRING',
|
||
|
types: ['FLAG'],
|
||
|
required: true
|
||
|
},
|
||
|
{
|
||
|
name: 'emojis',
|
||
|
aliases: ['emoji'],
|
||
|
type: 'BOOLEAN',
|
||
|
types: ['FLAG'],
|
||
|
default: true
|
||
|
},
|
||
|
{
|
||
|
name: 'reactions',
|
||
|
aliases: ['reaction'],
|
||
|
type: 'BOOLEAN',
|
||
|
types: ['FLAG'],
|
||
|
default: true
|
||
|
},
|
||
|
{
|
||
|
name: 'images',
|
||
|
aliases: ['image'],
|
||
|
type: 'BOOLEAN',
|
||
|
types: ['FLAG'],
|
||
|
default: true
|
||
|
},
|
||
|
{
|
||
|
name: 'attachments',
|
||
|
aliases: ['attachment'],
|
||
|
type: 'BOOLEAN',
|
||
|
types: ['FLAG'],
|
||
|
default: true
|
||
|
},
|
||
|
{
|
||
|
name: 'after',
|
||
|
usage: '<message-id>',
|
||
|
type: 'INTEGER',
|
||
|
types: ['FLAG'],
|
||
|
default: true,
|
||
|
required: true
|
||
|
},
|
||
|
{
|
||
|
name: 'before',
|
||
|
usage: '<message-id>',
|
||
|
type: 'INTEGER',
|
||
|
types: ['FLAG'],
|
||
|
default: true,
|
||
|
required: true
|
||
|
},
|
||
|
{
|
||
|
name: 'and',
|
||
|
type: 'BOOLEAN',
|
||
|
types: ['FLAG'],
|
||
|
default: true
|
||
|
},
|
||
|
{
|
||
|
name: 'not',
|
||
|
type: 'BOOLEAN',
|
||
|
types: ['FLAG'],
|
||
|
default: true
|
||
|
},
|
||
|
{
|
||
|
name: 'silent',
|
||
|
type: 'BOOLEAN',
|
||
|
types: ['FLAG'],
|
||
|
default: true
|
||
|
}
|
||
|
],
|
||
|
guildOnly: true,
|
||
|
showUsage: true,
|
||
|
throttling: {
|
||
|
usages: 2,
|
||
|
duration: 10
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
async execute(message, { params }) {
|
||
|
|
||
|
let { parsed, parameters } = await this.client.resolver.infinite(params, [ //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'
|
||
|
});
|
||
|
|
||
|
const 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'
|
||
|
});
|
||
|
}
|
||
|
|
||
|
const reason = parameters.slice(1).join(' ');
|
||
|
|
||
|
return this.client.moderationManager
|
||
|
.handleInfraction(Prune, message, {
|
||
|
targets: parsed,
|
||
|
data: {
|
||
|
amount: int,
|
||
|
message: message.id
|
||
|
},
|
||
|
reason
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
module.exports = PruneCommand;
|