removed permission checking in verify function for infractions

This commit is contained in:
nolan 2020-08-03 01:32:34 -07:00
parent ef2cbc0a8f
commit d0012fb9be
12 changed files with 27 additions and 72 deletions

View File

@ -19,6 +19,9 @@ Successfully granted targets {targets} the following permissions: {permissions}{
[C_GRANT_SUCCESSCHANNELS]
in channel{plural} {channels}
[C_GRANT_WARNING]
You granted a command from the **Administration** module. This is potentially dangerous, as whoever you granted the administration commands to could have access to vital parts of the server. Only grant administration commands to people you trust.
//Revoke Command
[C_REVOKE_DESCRIPTION]
@ -34,7 +37,7 @@ There was an issue pushing the permissions to the database. Contact a bot develo
[C_REVOKE_SUCCESS]
Successfully revoked targets {targets} the following permissions: {permissions}{channel}.
[C_GRANT_SUCCESSCHANNELS]
[C_REVOKE_SUCCESSCHANNELS]
in channel{plural} {channels}
//Permissions Command

View File

@ -1,5 +1,6 @@
const { Command } = require('../../../../interfaces/');
const { GuildMember } = require('../../../../extensions/');
const { Emojis } = require('../../../../../util/');
class GrantCommand extends Command {
@ -50,8 +51,9 @@ class GrantCommand extends Command {
const permissions = this.client.registry.components.filter((c) => c.type === 'command' ||
c.type === 'module');
let warning = false;
let parsedPermissions = [];
if(parameters.join(' ') === 'all') {
if(parameters.join(' ').toLowerCase() === 'all') {
parsedPermissions = this.client.registry.components.filter((c) => c.type === 'command').map((c) => c.resolveable);
} else {
for(const perm of parameters) {
@ -59,9 +61,13 @@ class GrantCommand extends Command {
if(!search) continue;
if(search.type === 'module') {
for(const component of search.components.values()) {
if(component.type === 'command') parsedPermissions.push(component.resolveable);
if(component.type === 'command') {
if(component.module.id === 'administration') warning = true;
parsedPermissions.push(component.resolveable);
}
}
} else {
if(search.module.id === 'administration') warning = true;
parsedPermissions.push(search.resolveable);
}
}
@ -129,12 +135,22 @@ class GrantCommand extends Command {
await message.respond(message.format('C_GRANT_DATABASEERROR'), { emoji: 'failure' });
return undefined;
}
return message.respond(message.format('C_GRANT_SUCCESS', {
targets: parsed.map((p) => p instanceof GuildMember ? `**${p.user.tag}**` : `**${p.name}**`).join(' '),
permissions: parsedPermissions.map((p) => `\`${p}\``).join(', '),
channel: args.channel ? ` ${message.format('C_GRANT_SUCCESSCHANNELS', { channels: args.channel.value.map((c) => `**#${c.name}**`).join(', '), plural: args.channel.value.length === 1 ? '' : 's' })}` : ''
}), { emoji: 'success' });
}), {
emoji: 'success',
embed: warning ? {
author: {
name: `${Emojis.warning} Warning`
},
description: message.format('C_GRANT_WARNING'),
color: 0xffe15c
} : null
});
}

View File

@ -25,7 +25,7 @@ class SnipeCommand extends Command {
}
async execute(message, { params, args }) {
async execute(message, { params }) {
let channel = await this.client.resolver.resolveChannel(params.join(' '), true, message.guild, (channel) => channel.type === 'text');
if(!channel) channel = message.channel; //eslint-disable-line prefer-destructuring

View File

@ -172,17 +172,6 @@ class PruneInfraction extends Infraction {
description() {
return `\n${this.guild.format('INFRACTION_DESCRIPTIONAMOUNT', { amount: this.data.amount })}`;
}
verify() {
const missing = this.guild._checkPermissions(this.message, 'command:prune');
if(missing.length > 0) {
return super._fail('C_PRUNE_INSUFFICIENTPERMISSIONS');
}
return super._verify();
}
}

View File

@ -48,11 +48,6 @@ class RemoveroleInfraction extends Infraction {
async verify() {
const missing = this.guild._checkPermissions(this.message, 'command:removerole');
if(missing.length > 0) {
return super._fail('C_REMOVEROLE_INSUFFICIENTPERMISSIONS');
}
if (this.guild.ownerID === this.executor.id) return this._succeed();
const { highest } = this.executorMember.roles;
const filtered = this.data.roles.filter((r) => r.comparePositionTo(highest) < 0);

View File

@ -54,17 +54,6 @@ class SlowmodeInfraction extends Infraction {
return `\n${this.guild.format('INFRACTION_DESCRIPTIONDURATION', { duration: Util.duration(this.data.seconds) })}`;
}
verify() {
const missing = this.guild._checkPermissions(this.message, 'command:slowmode');
if(missing.length > 0) {
return super._fail('C_SLOWMODE_INSUFFICIENTPERMISSIONS');
}
return super._verify();
}
}
module.exports = SlowmodeInfraction;

View File

@ -52,11 +52,6 @@ class SoftbanInfraction extends Infraction {
}
verify() {
const missing = this.guild._checkPermissions(this.message, 'command:softban');
if(missing.length > 0) {
return super._fail('C_SOFTBAN_INSUFFICIENTPERMISSIONS');
}
if(this.member instanceof GuildMember) {
if(!this.member.bannable) return this._fail('C_SOFTBAN_CANNOTBESOFTBANNED');

View File

@ -35,17 +35,6 @@ class StrikeInfraction extends Infraction {
return this._succeed();
}
verify() {
const missing = this.guild._checkPermissions(this.message, 'command:strike');
if(missing.length > 0) {
return super._fail('C_SLOWMODE_INSUFFICIENTPERMISSIONS');
}
return super._verify();
}
}
module.exports = StrikeInfraction;

View File

@ -51,11 +51,6 @@ class UnbanInfraction extends Infraction {
}
async verify() {
const missing = this.guild._checkPermissions(this.message, 'command:unban');
if(missing.length > 0) {
return super._fail('C_UNBAN_INSUFFICIENTPERMISSIONS');
}
let ban = null;
try {

View File

@ -104,17 +104,6 @@ class MuteInfraction extends Infraction {
}
async verify() {
const missing = this.guild._checkPermissions(this.message, 'command:unmute');
if(missing.length > 0) {
return super._fail('C_UNMUTE_INSUFFICIENTPERMISSIONS');
}
return super._verify();
}
}

View File

@ -45,11 +45,6 @@ class VckickInfraction extends Infraction {
verify() {
const missing = this.guild._checkPermissions(this.message, 'command:vckick');
if(missing.length > 0) {
return super._fail('C_VCKICK_INSUFFICIENTPERMISSIONS');
}
if(!this.member.voice.channel) return this._fail('C_VCKICK_NOCHANNEL');
return super._verify();

View File

@ -37,9 +37,9 @@ class WarnInfraction extends Infraction {
async verify() {
const permissions = await this.client.moderationManager.permissions.execute(this.message, this.message.command);
if(permissions.error) return super._fail('C_WARN_INSUFFICIENTPERMISSIONS');
// NOTE: If I want to readd permission checking for escalations.
// const permissions = await this.client.moderationManager.permissions.execute(this.message, this.message.command);
// if(permissions.error) return super._fail('C_WARN_INSUFFICIENTPERMISSIONS');
return super._verify();