mirror of
https://github.com/danbulant/Shasha
synced 2026-07-05 11:00:58 +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';
|
'use strict';
|
||||||
|
|
||||||
|
const { Role, Message } = require("discord.js");
|
||||||
|
|
||||||
const { parseDash, defaultImageEmbed, trySend, getRole, cleanMentionID } = require("../../../resources/functions"),
|
const { parseDash, defaultImageEmbed, trySend, getRole, cleanMentionID } = require("../../../resources/functions"),
|
||||||
fn = require("./duration"),
|
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]`";
|
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 = "";
|
resultMsg = "";
|
||||||
if (!args?.[1]) setEmb.setDescription(ARGS_TEXT); else {
|
if (!args?.[1]) setEmb.setDescription(ARGS_TEXT); else {
|
||||||
for (const ARG of args) {
|
for (const ARG of args) {
|
||||||
|
if (ARG === "-") continue;
|
||||||
if (ARG.startsWith("r ")) {
|
if (ARG.startsWith("r ")) {
|
||||||
const key = cleanMentionID(ARG.slice(2));
|
const key = cleanMentionID(ARG.slice(2));
|
||||||
if (key === "none") {
|
if (key === "none") {
|
||||||
role = false;
|
role = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (key?.length > 0) role = getRole(msg.guild, key)?.id;
|
else if (key?.length) role = getRole(msg.guild, key);
|
||||||
if (role === undefined) resultMsg += `No role found for: **${ARG}**\n`; else msg.guild.DB.settings.mute.role = role;
|
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 ")) {
|
if (ARG.startsWith("d ")) {
|
||||||
const D = ARG.slice(2).trim();
|
const D = ARG.slice(2).trim();
|
||||||
console.log(D);
|
// console.log(D);
|
||||||
if (/^[\-\+]?\d{1,16}(?![^ymwdhs])[ymwdhs]?o?/i.test(D)) {
|
if (/^[\-\+]?\d{1,16}(?![^ymwdhs])[ymwdhs]?o?/i.test(D)) {
|
||||||
duration = fn.duration(msg.createdAt, D);
|
duration = fn.duration(msg.createdAt, D);
|
||||||
msg.guild.DB.settings.mute.defaultDuration = duration;
|
msg.guild.DB.settings.mute.defaultDuration = duration;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue