forked from Galactic/galactic-bot
117 lines
3.8 KiB
JavaScript
117 lines
3.8 KiB
JavaScript
const { Command } = require('../../../../interfaces/');
|
|
const { Mute } = require('../../../../moderation/infractions/');
|
|
|
|
class MuteCommand extends Command {
|
|
|
|
constructor(client) {
|
|
|
|
super(client, {
|
|
name: 'mute',
|
|
module: 'moderation',
|
|
aliases: [
|
|
'tempmute'
|
|
],
|
|
usage: "<member..> [duration] [reason]",
|
|
clientPermissions: ['MANAGE_ROLES'],
|
|
memberPermissions: ['MANAGE_ROLES'],
|
|
examples: [
|
|
"1h @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.MUTE;
|
|
},
|
|
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.MUTE;
|
|
}
|
|
},
|
|
{
|
|
name: 'prune',
|
|
aliases: ['purge'],
|
|
type: 'INTEGER',
|
|
types: ['FLAG'],
|
|
usage: '<amount>',
|
|
default: 50,
|
|
min: 2, max: 50,
|
|
ignoreInvalid: true
|
|
},
|
|
{
|
|
name: 'force',
|
|
type: 'BOOLEAN',
|
|
types: ['FLAG'],
|
|
default: true
|
|
},
|
|
{
|
|
name: 'silent',
|
|
type: 'BOOLEAN',
|
|
types: ['FLAG'],
|
|
default: true
|
|
}
|
|
],
|
|
guildOnly: true,
|
|
showUsage: true
|
|
});
|
|
}
|
|
|
|
async execute(message, { params }) {
|
|
|
|
const { parsed, parameters } = await this.client.resolver.infinite(params, [
|
|
this.client.resolver.resolveMember.bind(this.client.resolver)
|
|
], true, message.guild);
|
|
|
|
if(parsed.length === 0) return message.respond(message.format('C_MUTE_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) {
|
|
const setting = await message.guild._settings.mute;
|
|
if(message._caller === 'tempmute') return message.respond(message.format('C_MUTE_DURATIONREQUIRED'), { emoji: 'failure' });
|
|
if(setting.permanent) {
|
|
time = 0;
|
|
} else {
|
|
time = setting.defaultDuration;
|
|
}
|
|
} else {
|
|
reason = reason.slice(1).join(' ');
|
|
}
|
|
|
|
if(time !== 0) {
|
|
if(time < 60 || time > 2629801) { // approx. over 1 month (according to resolveTime)
|
|
return message.respond(message.format('C_MUTE_DURATIONEXCEPTION'), { emoji: 'failure' });
|
|
}
|
|
}
|
|
|
|
return this.client.moderationManager
|
|
.handleInfraction(Mute, message, {
|
|
targets: parsed,
|
|
duration: time,
|
|
reason
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = MuteCommand; |