diff --git a/language/languages/en_us/commands/en_us_administration.lang b/language/languages/en_us/commands/en_us_administration.lang index f0e05c3..3acdca3 100644 --- a/language/languages/en_us/commands/en_us_administration.lang +++ b/language/languages/en_us/commands/en_us_administration.lang @@ -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 diff --git a/structure/client/components/commands/administration/Grant.js b/structure/client/components/commands/administration/Grant.js index a696057..9e7ea6c 100644 --- a/structure/client/components/commands/administration/Grant.js +++ b/structure/client/components/commands/administration/Grant.js @@ -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 + }); } diff --git a/structure/client/components/commands/moderation/Snipe.js b/structure/client/components/commands/moderation/Snipe.js index 61892b5..edcf002 100644 --- a/structure/client/components/commands/moderation/Snipe.js +++ b/structure/client/components/commands/moderation/Snipe.js @@ -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 diff --git a/structure/moderation/infractions/Prune.js b/structure/moderation/infractions/Prune.js index 3cb5195..ae9410b 100644 --- a/structure/moderation/infractions/Prune.js +++ b/structure/moderation/infractions/Prune.js @@ -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(); - - } } diff --git a/structure/moderation/infractions/Removerole.js b/structure/moderation/infractions/Removerole.js index 8f4d856..5907978 100644 --- a/structure/moderation/infractions/Removerole.js +++ b/structure/moderation/infractions/Removerole.js @@ -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); diff --git a/structure/moderation/infractions/Slowmode.js b/structure/moderation/infractions/Slowmode.js index 1377de1..0b9b53f 100644 --- a/structure/moderation/infractions/Slowmode.js +++ b/structure/moderation/infractions/Slowmode.js @@ -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; \ No newline at end of file diff --git a/structure/moderation/infractions/Softban.js b/structure/moderation/infractions/Softban.js index a65c6af..7f1c3df 100644 --- a/structure/moderation/infractions/Softban.js +++ b/structure/moderation/infractions/Softban.js @@ -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'); diff --git a/structure/moderation/infractions/Strike.js b/structure/moderation/infractions/Strike.js index fe2cf3b..9c02c07 100644 --- a/structure/moderation/infractions/Strike.js +++ b/structure/moderation/infractions/Strike.js @@ -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; \ No newline at end of file diff --git a/structure/moderation/infractions/Unban.js b/structure/moderation/infractions/Unban.js index 4c87947..e8401b6 100644 --- a/structure/moderation/infractions/Unban.js +++ b/structure/moderation/infractions/Unban.js @@ -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 { diff --git a/structure/moderation/infractions/Unmute.js b/structure/moderation/infractions/Unmute.js index f5208d1..7cffc2c 100644 --- a/structure/moderation/infractions/Unmute.js +++ b/structure/moderation/infractions/Unmute.js @@ -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(); - - } - } diff --git a/structure/moderation/infractions/Vckick.js b/structure/moderation/infractions/Vckick.js index a285483..0f5b79e 100644 --- a/structure/moderation/infractions/Vckick.js +++ b/structure/moderation/infractions/Vckick.js @@ -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(); diff --git a/structure/moderation/infractions/Warn.js b/structure/moderation/infractions/Warn.js index 5f43ef9..8b9a596 100644 --- a/structure/moderation/infractions/Warn.js +++ b/structure/moderation/infractions/Warn.js @@ -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();