diff --git a/src/structure/client/ModerationManager.js b/src/structure/client/ModerationManager.js index cac92a5..9455e55 100644 --- a/src/structure/client/ModerationManager.js +++ b/src/structure/client/ModerationManager.js @@ -5,7 +5,7 @@ const { inspect } = require('util'); const { Emojis, Constants } = require('../../constants'); const { Util, Logger } = require('../../utilities'); -const { Warn, Unmute, Mute, Kick, Softban, Unban, Ban, Addrole, Removerole, Lockdown, Unlockdown } = require('../components/infractions'); +const { Warn, Unmute, Mute, Kick, Softban, Unban, Ban, Addrole, Removerole, Lockdown, Unlockdown } = require('../infractions'); const Constant = { MaxTargets: 10, //10+(10*premium-tier), theoretical max = 40 @@ -252,7 +252,10 @@ class ModerationManager { points = info.points || modpoints.points[type]; expiration = info.expiration || modpoints.expirations[type]; if(reason) for (const [phrase, amount] of Object.entries(modpoints.associations)) { - if (reason.toLowerCase().includes(phrase)) points = amount; + if (reason.toLowerCase().includes(phrase)) { + points = amount; + break; + } } } diff --git a/src/structure/components/commands/moderation/Ban.js b/src/structure/components/commands/moderation/Ban.js index b5ce5b9..0748166 100644 --- a/src/structure/components/commands/moderation/Ban.js +++ b/src/structure/components/commands/moderation/Ban.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require("../../../interfaces"); -const { Ban } = require("../../infractions/"); +const { Ban } = require("../../../infractions/"); class BanCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Dehoist.js b/src/structure/components/commands/moderation/Dehoist.js index a8745da..9dd214d 100644 --- a/src/structure/components/commands/moderation/Dehoist.js +++ b/src/structure/components/commands/moderation/Dehoist.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require("../../../interfaces"); -const { Nickname } = require("../../infractions"); +const { Nickname } = require("../../../infractions"); class DehoistCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Kick.js b/src/structure/components/commands/moderation/Kick.js index 79e6471..4b08d47 100644 --- a/src/structure/components/commands/moderation/Kick.js +++ b/src/structure/components/commands/moderation/Kick.js @@ -1,5 +1,5 @@ const { ModerationCommand } = require('../../../interfaces'); -const { Kick } = require('../../infractions'); +const { Kick } = require('../../../infractions'); class KickCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Lockdown.js b/src/structure/components/commands/moderation/Lockdown.js index 5ff4051..b06dc81 100644 --- a/src/structure/components/commands/moderation/Lockdown.js +++ b/src/structure/components/commands/moderation/Lockdown.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require('../../../interfaces'); -const { Lockdown } = require('../../infractions'); +const { Lockdown } = require('../../../infractions'); class LockdownCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Mute.js b/src/structure/components/commands/moderation/Mute.js index a605b47..7f78540 100644 --- a/src/structure/components/commands/moderation/Mute.js +++ b/src/structure/components/commands/moderation/Mute.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require('../../../interfaces'); -const { Mute } = require('../../infractions'); +const { Mute } = require('../../../infractions'); class MuteCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Nickname.js b/src/structure/components/commands/moderation/Nickname.js index 9d87e2d..332bfd1 100644 --- a/src/structure/components/commands/moderation/Nickname.js +++ b/src/structure/components/commands/moderation/Nickname.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require("../../../interfaces"); -const { Nickname } = require("../../infractions"); +const { Nickname } = require("../../../infractions"); class NicknameCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Note.js b/src/structure/components/commands/moderation/Note.js index c9351ba..9b7061b 100644 --- a/src/structure/components/commands/moderation/Note.js +++ b/src/structure/components/commands/moderation/Note.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require("../../../interfaces"); -const { Note } = require("../../infractions"); +const { Note } = require("../../../infractions"); class NoteCommand extends ModerationCommand { constructor(client) { diff --git a/src/structure/components/commands/moderation/Prune.js b/src/structure/components/commands/moderation/Prune.js index 412ac0b..10530fb 100644 --- a/src/structure/components/commands/moderation/Prune.js +++ b/src/structure/components/commands/moderation/Prune.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require('../../../interfaces'); -const { Prune } = require('../../infractions'); +const { Prune } = require('../../../infractions'); class PruneCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Roles.js b/src/structure/components/commands/moderation/Roles.js index a01c73d..263faa7 100644 --- a/src/structure/components/commands/moderation/Roles.js +++ b/src/structure/components/commands/moderation/Roles.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require("../../../interfaces"); -const { Addrole, Removerole } = require("../../infractions"); +const { Addrole, Removerole } = require("../../../infractions"); class AddroleCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Slowmode.js b/src/structure/components/commands/moderation/Slowmode.js index a492680..4e6d13c 100644 --- a/src/structure/components/commands/moderation/Slowmode.js +++ b/src/structure/components/commands/moderation/Slowmode.js @@ -1,5 +1,5 @@ const { ModerationCommand } = require("../../../interfaces"); -const { Slowmode } = require("../../infractions"); +const { Slowmode } = require("../../../infractions"); class SlowmodeCommand extends ModerationCommand { constructor(client) { diff --git a/src/structure/components/commands/moderation/Softban.js b/src/structure/components/commands/moderation/Softban.js index 6693d2f..623bdb3 100644 --- a/src/structure/components/commands/moderation/Softban.js +++ b/src/structure/components/commands/moderation/Softban.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require("../../../interfaces"); -const { Softban } = require("../../infractions"); +const { Softban } = require("../../../infractions"); class SoftbanCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Unban.js b/src/structure/components/commands/moderation/Unban.js index ad25648..e3b8735 100644 --- a/src/structure/components/commands/moderation/Unban.js +++ b/src/structure/components/commands/moderation/Unban.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require("../../../interfaces"); -const { Unban } = require("../../infractions"); +const { Unban } = require("../../../infractions"); class UnbanCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Unlockdown.js b/src/structure/components/commands/moderation/Unlockdown.js index 061fe4d..9e94f59 100644 --- a/src/structure/components/commands/moderation/Unlockdown.js +++ b/src/structure/components/commands/moderation/Unlockdown.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require('../../../interfaces'); -const { Unlockdown } = require('../../infractions'); +const { Unlockdown } = require('../../../infractions'); class UnlockdownCommand extends ModerationCommand { diff --git a/src/structure/components/commands/moderation/Unmute.js b/src/structure/components/commands/moderation/Unmute.js index 9ec3d56..0eae2b8 100644 --- a/src/structure/components/commands/moderation/Unmute.js +++ b/src/structure/components/commands/moderation/Unmute.js @@ -1,5 +1,5 @@ const { ModerationCommand, CommandError } = require('../../../interfaces'); -const { Unmute } = require('../../infractions'); +const { Unmute } = require('../../../infractions'); class UnmuteCommand extends ModerationCommand { @@ -12,7 +12,7 @@ class UnmuteCommand extends ModerationCommand { guildOnly: true, showUsage: true, memberPermissions: ['ModerateMembers'], - clientPermissions: ['ManageRoles', 'ModerateMembers'], + // clientPermissions: ['ManageRoles', 'ModerateMembers'], skipOptions: ['points', 'expiration', 'prune', 'force'] }); } @@ -20,6 +20,11 @@ class UnmuteCommand extends ModerationCommand { async execute(interaction, { users, ...args }) { if (!users) throw new CommandError(interaction, { index: 'MODERATION_MISSING_USERS' }); + const { guild } = interaction; + const settings = await guild.settings(); + const { type } = settings.mute; + if (type === 3 && !guild.members.me.permissions.has('ModerateMembers')) throw new CommandError(interaction, { index: 'INHIBITOR_CLIENTPERMISSIONS_ERROR', params: { command: this.name, missing: 'ModerateMembers' } }); + else if (!guild.members.me.permissions.has('ManageRoles')) throw new CommandError(interaction, { index: 'INHIBITOR_CLIENTPERMISSIONS_ERROR', params: { command: this.name, missing: 'ManageRoles' } }); return this.client.moderationManager.handleInfraction(Unmute, interaction, { targets: users.value, diff --git a/src/structure/components/commands/moderation/Warn.js b/src/structure/components/commands/moderation/Warn.js index 7df37d4..44da670 100644 --- a/src/structure/components/commands/moderation/Warn.js +++ b/src/structure/components/commands/moderation/Warn.js @@ -1,5 +1,5 @@ const { ModerationCommand } = require("../../../interfaces"); -const { Warn } = require("../../infractions"); +const { Warn } = require("../../../infractions"); class WarnCommand extends ModerationCommand { constructor(client) { diff --git a/src/structure/components/observers/Automoderation.js b/src/structure/components/observers/Automoderation.js index 5a77cff..00a7bef 100644 --- a/src/structure/components/observers/Automoderation.js +++ b/src/structure/components/observers/Automoderation.js @@ -5,7 +5,7 @@ const { stripIndents } = require('common-tags'); const { Observer } = require('../../interfaces'); const { BinaryTree, Util, FilterUtil } = require('../../../utilities'); -const { Warn, Mute, Kick, Softban, Ban } = require('../infractions'); +const { Warn, Mute, Kick, Softban, Ban } = require('../../infractions'); const { ComponentType, ButtonStyle } = require('discord.js'); const CONSTANTS = { @@ -649,7 +649,11 @@ module.exports = class AutoModeration extends Observer { if (actions.length) { - const action = actions.find((act) => { + let action = actions.find((act) => { + return act.trigger <= ids.length; + }); + + if(!action) action = actions.find((act) => { return act.trigger === 'generic'; }); diff --git a/src/structure/infractions/Addrole.js b/src/structure/infractions/Addrole.js index d66c691..e0ab45d 100644 --- a/src/structure/infractions/Addrole.js +++ b/src/structure/infractions/Addrole.js @@ -1,6 +1,6 @@ /* eslint-disable indent */ const { GuildMember } = require('discord.js'); -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); class AddroleInfraction extends Infraction { diff --git a/src/structure/infractions/Ban.js b/src/structure/infractions/Ban.js index c3efa87..b658092 100644 --- a/src/structure/infractions/Ban.js +++ b/src/structure/infractions/Ban.js @@ -1,5 +1,5 @@ /* eslint-disable indent */ -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); const { GuildMember } = require('discord.js'); class BanInfraction extends Infraction { diff --git a/src/structure/infractions/Kick.js b/src/structure/infractions/Kick.js index 12c3959..883f7d7 100644 --- a/src/structure/infractions/Kick.js +++ b/src/structure/infractions/Kick.js @@ -1,5 +1,5 @@ const { GuildMember } = require('discord.js'); -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); class KickInfraction extends Infraction { diff --git a/src/structure/infractions/Lockdown.js b/src/structure/infractions/Lockdown.js index 707902e..fb7b193 100644 --- a/src/structure/infractions/Lockdown.js +++ b/src/structure/infractions/Lockdown.js @@ -1,5 +1,5 @@ const { OverwriteType } = require('discord.js'); -const { Infraction } = require('../../interfaces/'); +const { Infraction } = require('../interfaces/'); const allowedPermissions = ['ManageMessages', 'ManageChannels']; diff --git a/src/structure/infractions/Mute.js b/src/structure/infractions/Mute.js index cd12b5d..68a0d43 100644 --- a/src/structure/infractions/Mute.js +++ b/src/structure/infractions/Mute.js @@ -1,6 +1,6 @@ /* eslint-disable indent */ const { GuildMember } = require('discord.js'); -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); class MuteInfraction extends Infraction { diff --git a/src/structure/infractions/Nickname.js b/src/structure/infractions/Nickname.js index 76f375e..5721dbe 100644 --- a/src/structure/infractions/Nickname.js +++ b/src/structure/infractions/Nickname.js @@ -1,8 +1,8 @@ -const { Infraction } = require('../../interfaces/'); +const { Infraction } = require('../interfaces/'); const escapeRegex = require('escape-string-regexp'); -const { Util } = require('../../../utilities'); -const { KillItWithFire } = require('../../../constants'); +const { Util } = require('../../utilities'); +const { KillItWithFire } = require('../../constants'); const { GuildMember } = require('discord.js'); const Constants = { diff --git a/src/structure/infractions/Note.js b/src/structure/infractions/Note.js index 385b3f7..562dde6 100644 --- a/src/structure/infractions/Note.js +++ b/src/structure/infractions/Note.js @@ -1,4 +1,4 @@ -const { Infraction } = require('../../interfaces/'); +const { Infraction } = require('../interfaces/'); class NoteInfraction extends Infraction { diff --git a/src/structure/infractions/Prune.js b/src/structure/infractions/Prune.js index 8340413..78916a8 100644 --- a/src/structure/infractions/Prune.js +++ b/src/structure/infractions/Prune.js @@ -1,4 +1,4 @@ -const { Infraction } = require('../../interfaces/'); +const { Infraction } = require('../interfaces/'); const { Collection } = require('@discordjs/collection'); const { MessageType } = require('discord.js'); diff --git a/src/structure/infractions/Removerole.js b/src/structure/infractions/Removerole.js index 17edc9f..58ff10b 100644 --- a/src/structure/infractions/Removerole.js +++ b/src/structure/infractions/Removerole.js @@ -1,6 +1,6 @@ /* eslint-disable indent */ const { GuildMember } = require('discord.js'); -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); class RemoveroleInfraction extends Infraction { diff --git a/src/structure/infractions/Slowmode.js b/src/structure/infractions/Slowmode.js index b52f3b0..2c99d25 100644 --- a/src/structure/infractions/Slowmode.js +++ b/src/structure/infractions/Slowmode.js @@ -1,5 +1,5 @@ -const { Infraction } = require('../../interfaces'); -const { Util } = require('../../../utilities'); +const { Infraction } = require('../interfaces'); +const { Util } = require('../../utilities'); class SlowmodeInfraction extends Infraction { diff --git a/src/structure/infractions/Softban.js b/src/structure/infractions/Softban.js index 1f45406..d4f5643 100644 --- a/src/structure/infractions/Softban.js +++ b/src/structure/infractions/Softban.js @@ -1,4 +1,4 @@ -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); const { GuildMember } = require('discord.js'); class SoftbanInfraction extends Infraction { diff --git a/src/structure/infractions/Unban.js b/src/structure/infractions/Unban.js index a9234f2..4e25ba2 100644 --- a/src/structure/infractions/Unban.js +++ b/src/structure/infractions/Unban.js @@ -1,5 +1,5 @@ /* eslint-disable indent */ -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); class UnbanInfraction extends Infraction { diff --git a/src/structure/infractions/Unlockdown.js b/src/structure/infractions/Unlockdown.js index 6086f92..9349510 100644 --- a/src/structure/infractions/Unlockdown.js +++ b/src/structure/infractions/Unlockdown.js @@ -1,4 +1,4 @@ -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); class UnlockdownInfraction extends Infraction { diff --git a/src/structure/infractions/Unmute.js b/src/structure/infractions/Unmute.js index 38b08cf..5b49915 100644 --- a/src/structure/infractions/Unmute.js +++ b/src/structure/infractions/Unmute.js @@ -1,6 +1,6 @@ /* eslint-disable indent */ const { GuildMember } = require('discord.js'); -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); class UnmuteInfraction extends Infraction { diff --git a/src/structure/infractions/Vckick.js b/src/structure/infractions/Vckick.js index 7e57f80..0d834f7 100644 --- a/src/structure/infractions/Vckick.js +++ b/src/structure/infractions/Vckick.js @@ -1,5 +1,5 @@ const { GuildMember } = require('discord.js'); -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); class VckickInfraction extends Infraction { diff --git a/src/structure/infractions/Warn.js b/src/structure/infractions/Warn.js index 38a2aef..3181592 100644 --- a/src/structure/infractions/Warn.js +++ b/src/structure/infractions/Warn.js @@ -1,5 +1,5 @@ const { GuildMember } = require('discord.js'); -const { Infraction } = require('../../interfaces'); +const { Infraction } = require('../interfaces'); class WarnInfraction extends Infraction { diff --git a/src/structure/interfaces/Infraction.js b/src/structure/interfaces/Infraction.js index d118bab..a70e2b4 100644 --- a/src/structure/interfaces/Infraction.js +++ b/src/structure/interfaces/Infraction.js @@ -101,7 +101,7 @@ class Infraction { this._logMessage = await this._moderationLog.send({ embeds: [this._embed()] }); this.modLogMessageId = this._logMessage.id; } catch (e) { - console.log(e); + // console.log(e); } //eslint-disable-line no-empty }