113 lines
3.5 KiB
JavaScript
113 lines
3.5 KiB
JavaScript
|
const { Command } = require('../../../../interfaces/');
|
||
|
const { Nickname } = require('../../../../moderation/infractions/');
|
||
|
|
||
|
class NicknameCommand extends Command {
|
||
|
|
||
|
constructor(client) {
|
||
|
|
||
|
super(client, {
|
||
|
name: 'nickname',
|
||
|
module: 'moderation',
|
||
|
aliases: [
|
||
|
'nick',
|
||
|
'dehoist'
|
||
|
],
|
||
|
usage: "<member..> [name] [reason]",
|
||
|
clientPermissions: ['MANAGE_NICKNAMES'],
|
||
|
memberPermissions: ['MANAGE_NICKNAMES'],
|
||
|
examples: [
|
||
|
'nick @nolan#2887 "censored name" inappropriate username',
|
||
|
"dehoist @Navy#1998 hoisting ontop of member list"
|
||
|
],
|
||
|
rawExamples: 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_NICKNAME_MISSINGMEMBERS'), {
|
||
|
emoji: 'failure'
|
||
|
});
|
||
|
|
||
|
let name = null;
|
||
|
let reason = parameters;
|
||
|
|
||
|
const dehoist = message._caller === 'dehoist';
|
||
|
if(!dehoist) {
|
||
|
name = parameters[0]; //eslint-disable-line prefer-destructuring
|
||
|
if(!name) {
|
||
|
return message.respond(message.format('C_NICKNAME_MISSINGNAME'), {
|
||
|
emoji: 'failure'
|
||
|
});
|
||
|
}
|
||
|
reason = reason.slice(1);
|
||
|
}
|
||
|
|
||
|
return this.client.moderationManager
|
||
|
.handleInfraction(Nickname, message, {
|
||
|
targets: parsed,
|
||
|
data: {
|
||
|
dehoist,
|
||
|
name
|
||
|
},
|
||
|
reason: reason.join(' ')
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
module.exports = NicknameCommand;
|