mirror of
https://github.com/danbulant/Shasha
synced 2026-06-17 13:21:09 +00:00
higher mute role warning
This commit is contained in:
parent
799bc63966
commit
ffbb6cafdd
1 changed files with 9 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue