From ffbb6cafdde99949d97b16448807a4211720fadd Mon Sep 17 00:00:00 2001 From: Neko-Life Date: Fri, 6 Aug 2021 11:27:29 +0700 Subject: [PATCH] higher mute role warning --- cmds/moderation/src/muteSetting.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmds/moderation/src/muteSetting.js b/cmds/moderation/src/muteSetting.js index 04d789d..ae54f3f 100644 --- a/cmds/moderation/src/muteSetting.js +++ b/cmds/moderation/src/muteSetting.js @@ -1,5 +1,7 @@ 'use strict'; +const { Role, Message } = require("discord.js"); + const { parseDash, defaultImageEmbed, trySend, getRole, cleanMentionID } = require("../../../resources/functions"), fn = require("./duration"), ARGS_TEXT = "Args:\n`-r` Role: `role_[name|mention|ID]`,\n`-d` Duration: `[duration]` - Format: `number_[y|mo|w|d|h|m|s]`"; @@ -14,18 +16,22 @@ module.exports = (msg, arg) => { resultMsg = ""; if (!args?.[1]) setEmb.setDescription(ARGS_TEXT); else { for (const ARG of args) { + if (ARG === "-") continue; if (ARG.startsWith("r ")) { const key = cleanMentionID(ARG.slice(2)); if (key === "none") { role = false; continue; } - if (key?.length > 0) role = getRole(msg.guild, key)?.id; - if (role === undefined) resultMsg += `No role found for: **${ARG}**\n`; else msg.guild.DB.settings.mute.role = role; + else if (key?.length) role = getRole(msg.guild, key); + const RP = role?.position; + const CRP = msg.guild.member(msg.client.user).roles.highest.position; + if (role && (RP ? RP > CRP : false)) resultMsg += "**[WARNING]** Mute role position is higher than my highest role!\n"; + if (role === undefined) resultMsg += `No role found for: **${ARG}**\n`; else msg.guild.DB.settings.mute.role = role.id; } if (ARG.startsWith("d ")) { const D = ARG.slice(2).trim(); - console.log(D); + // console.log(D); if (/^[\-\+]?\d{1,16}(?![^ymwdhs])[ymwdhs]?o?/i.test(D)) { duration = fn.duration(msg.createdAt, D); msg.guild.DB.settings.mute.defaultDuration = duration;