Separate nickname & dehoist command, created a description for old -> new nicknames in embed.

This commit is contained in:
nolan 2021-06-10 22:39:40 -07:00
parent 8b499f6ccb
commit 860c0c0bfb
6 changed files with 149 additions and 24 deletions

View File

@ -0,0 +1,96 @@
const { Command } = require('../../../../interfaces/');
const { Nickname } = require('../../../../moderation/infractions/');
class DehoistCommand extends Command {
constructor(client) {
super(client, {
name: 'dehoist',
module: 'moderation',
usage: "<member..> [reason]",
clientPermissions: ['MANAGE_NICKNAMES'],
memberPermissions: ['MANAGE_NICKNAMES'],
examples: [
"@Navy#1998 hoisting ontop of the member list"
],
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,
throttling: {
usages: 2,
duration: 5
}
});
}
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_DEHOIST_MISSINGMEMBERS'), {
emoji: 'failure'
});
return this.client.moderationManager
.handleInfraction(Nickname, message, {
targets: parsed,
data: {
dehoist: true
},
reason: parameters.join(' ')
});
}
}
module.exports = DehoistCommand;

View File

@ -9,15 +9,13 @@ class NicknameCommand extends Command {
name: 'nickname',
module: 'moderation',
aliases: [
'nick',
'dehoist'
'nick'
],
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"
'nick @nolan#2887 "censored name" inappropriate username'
],
rawExamples: true,
arguments: [
@ -89,22 +87,19 @@ class NicknameCommand extends Command {
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);
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,
dehoist: false,
name
},
reason: reason.join(' ')

View File

@ -244,6 +244,23 @@ Bypasses the moderation point escalation.
[A_PRUNE_NICKNAME_DESCRIPTION]
Removes messages from the user.
//Dehoist Command
[A_SILENT_DEHOIST_DESCRIPTION]
Deletes the command message and the execution message.
[A_POINTS_DEHOIST_DESCRIPTION]
Assign moderation points to the user.
[A_EXPIRATION_DEHOIST_DESCRIPTION]
Assign a duration for the moderation points to expire.
[A_FORCE_DEHOIST_DESCRIPTION]
Bypasses the moderation point escalation.
[A_PRUNE_DEHOIST_DESCRIPTION]
Removes messages from the user.
//Removerole Command
[A_SILENT_REMOVEROLE_DESCRIPTION]
Deletes the command message and the execution message.

View File

@ -376,7 +376,7 @@ the slowmode was already set to that
//Nickname Command
[C_NICKNAME_DESCRIPTION]
Change the nickname of provided members or dehoist them. You will have to put the nickname in quotes in order to allow for spaced nicknames.
Change the nickname of provided members. You will have to put the nickname in quotes in order to allow for spaced nicknames.
[C_NICKNAME_MISSINGMEMBERS]
You must provide members to nickname.
@ -390,9 +390,16 @@ they had no hoisted characters in their nickname
[C_NICKNAME_INSUFFICIENTPERMISSIONS]
I don't have permission to manage nicknames
[C_NICKNAME_MISSINGPERMSSIONS]
[C_NICKNAME_MISSINGPERMISSIONS]
they have a higher role than I do
//Dehoist Command
[C_DEHOIST_DESCRIPTION]
Removes special characters from username or nickname that allow users to hoist themselves ontop of the member list.
[C_DEHOIST_MISSINGMEMBERS]
You must provide members to dehoist.
//Addrole Command
[C_ADDROLE_DESCRIPTION]
Add roles to provided members. The added roles cannot be a higher position than the executor's highest role.

View File

@ -303,4 +303,9 @@ Failed to {infraction} {targetType} {target} because {reason}.
//Addrole/Removerole Commands
[INFRACTION_DESCRIPTIONROLES]
**Role{plural}:** {roles}
**Role{plural}:** {roles}
//Nickname Command
[INFRACTION_DESCRIPTIONNICKNAME]
**Old Name:** {old}
**New Name:** {new}

View File

@ -1,6 +1,8 @@
const { Infraction } = require('../interfaces/');
const escapeRegex = require('escape-string-regexp');
const { Util } = require('../../../util/');
const Constants = {
Characters: ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '-', '=', '+', '"', "'", '`', '\\', '/', '[', ']', '>', '<', '.'],
RandomNames: ["Ashly Armistead", "Jenifer James", "Eleonora Espinosa", "Eleanore Ellerbee", "Marguerite Means", "Lore Lazar", "Cherilyn Calero", "Olevia Olvera", "Herman Horvat", "Elvin Elfrink", "Jennine Julian", "Pei Plude", "Kenisha Kirts", "Sherly Starbird", "Lashanda Louder", "Elizabeth Eakle", "Lyda Leard", "Penelope Petri", "Kimi Kissel", "Crista Crowe", "Mallory Mehta", "Bettina Bregman", "Marcie Moran", "James Jiles", "Clifton Capshaw", "Cher Curlee", "Brigid Bonier", "Lana Lehman", "Carletta Chalker", "Valene Viator", "Eugena Eder", "Samatha Shivers", "Hoyt Hard", "Karena King", "Tiffani Trott", "Joye Jeremiah", "Emely Espino", "Rowena Rowan", "Gillian Godbey", "Hailey Huggard", "Lillian Lander", "Shani Szabo", "Liberty Lamorte", "Tomika Thrift", "Garrett Grogan", "Vallie Valazquez", "Shin Secor", "Deangelo Divito", "Kacy Kimball", "Norris Northway", "Evelia Ernest", "Horacio Huey", "Christen Cyr", "Jada Janus", "Vanita Valero", "Abdul Addario", "Daniell Dingle", "Tangela Trull", "Jeanmarie Jimenez", "Georgia Gourlay", "Valery Vergara", "Chasidy Conrad", "Marlena Malin", "Kristeen Kesselman", "Jo Jeffries", "Terina Tworek", "Geri Gilbert", "Phuong Pratte", "Juanita Jess", "Audrea Ammon", "Shakita Stalter", "Rosamond Reese", "Shani Solorio", "Archie Augustyn", "Bridgett Behrman", "Susann Schmaltz", "Edgardo Engman", "Valerie Vice", "Cheyenne Claeys", "Kristina Kastner", "Lanita Labrum", "Kai Knick", "Lucien Lee", "Tameika Turley", "Octavia Obermiller", "Kia Kravitz", "Justina Jury", "Cortney Coppa", "Johnathan Joshi", "Arden Alphin", "Francis Feinberg", "Sal Suits", "Myles Marden", "Emmitt Engelmann", "Tara Tibbits", "Su Sprowl", "Isadora Ingrassia", "Janell Jarrard", "Kenyatta Kenley", "Mabelle Mccrady"]
@ -32,22 +34,21 @@ class NicknameInfraction extends Infraction {
}
async execute() {
let { dehoist, name } = this.data; //eslint-disable-line prefer-const
let { dehoist } = this.data; //eslint-disable-line prefer-const
this.data.oldName = this.member.nickname || this.member.user.username;
if(dehoist) {
const displayName = this.member.nickname || this.member.user.username;
const [, removed, fixed] = Regex.exec(displayName);
const [, removed, fixed] = Regex.exec(this.data.oldName);
if(!removed) return this._fail('C_NICKNAME_NOCHARACTERS');
if(fixed) {
name = fixed;
this.data.name = fixed;
} else {
name = this._generateName();
this.data.name = this._generateName();
}
}
try {
this.member.setNickname(name, this._reason);
this.member.setNickname(this.data.name, this._reason);
} catch(e) {
return this._fail('INFRACTION_ERROR');
}
@ -75,6 +76,10 @@ class NicknameInfraction extends Infraction {
}
description() {
return `\n${this.guild.format('INFRACTION_DESCRIPTIONNICKNAME', { old: Util.escapeMarkdown(this.data.oldName), new: Util.escapeMarkdown(this.data.name) })}`;
}
}
module.exports = NicknameInfraction;