From 17a6f7aab65a735b718ee30f79588a38b023376b Mon Sep 17 00:00:00 2001 From: Neko-Life Date: Mon, 26 Jul 2021 14:26:27 +0700 Subject: [PATCH] Change embed looks --- .xsh.sh | 1 + cmds/moderation/mute.js | 9 +++++---- cmds/moderation/unmute.js | 8 +++++--- resources/structures.js | 12 ++++++------ 4 files changed, 17 insertions(+), 13 deletions(-) create mode 100755 .xsh.sh diff --git a/.xsh.sh b/.xsh.sh new file mode 100755 index 0000000..ff81baa --- /dev/null +++ b/.xsh.sh @@ -0,0 +1 @@ +#!zsh \ No newline at end of file diff --git a/cmds/moderation/mute.js b/cmds/moderation/mute.js index c71d862..b3c2fb4 100644 --- a/cmds/moderation/mute.js +++ b/cmds/moderation/mute.js @@ -134,24 +134,25 @@ module.exports = class mute extends commando.Command { if (muted.length > 0) await msg.guild.addInfraction(infractionToDoc); - const emb = defaultImageEmbed(msg, null, "Infraction #" + infractionToDoc.infraction); + const emb = defaultEventLogEmbed(msg.guild); let mutedStr = "", mutedArr = []; if (muted.length > 0) for (const U of muted) { - const tU = "<@" + U + ">\n"; + const tU = "<@" + U + ">, "; if ((mutedStr + tU).length < 1000) mutedStr += tU; else mutedArr.push(U); } if (mutedArr.length > 0) mutedStr += `and ${mutedArr.length} more...`; + if (already.length > 0) emb.addField("Already muted", "<@" + already.join(">, <@") + ">\n\nDuration updated for these users"); - emb.setDescription("**Reason**\n" + reason) + emb.setTitle("Infraction #" + infractionToDoc.infraction) + .setDescription("**Reason**\n" + reason) .addField("Muted", mutedStr || "`[NONE]`") .addField("At", defaultDateFormat(duration.invoked), true) .addField("Until", duration.until ? defaultDateFormat(duration.until) : "Never", true) .addField("For", duration.duration?.strings.join(" ") || "Indefinite"); if (cant.length > 0) emb.addField("Can't mute", "<@" + cant.join(">, <@") + ">\n\n**You can't mute someone with higher position than you <:nekokekLife:852865942530949160>**"); - if (already.length > 0) emb.addField("Already muted", "<@" + already.join(">, <@") + ">\n\nDuration updated for these users"); return trySend(msg.client, msg, { content: resultMsg, embed: emb }); } diff --git a/cmds/moderation/unmute.js b/cmds/moderation/unmute.js index 3171278..5ac3dda 100644 --- a/cmds/moderation/unmute.js +++ b/cmds/moderation/unmute.js @@ -51,11 +51,13 @@ module.exports = class unmute extends commando.Command { }); } - const emb = defaultImageEmbed(msg, null, "Unmute"); - emb.setDescription("**Reason**\n" + reason) + const emb = defaultEventLogEmbed(msg.guild); + if (notMuted.length > 0) emb.addField("Wasn't muted", "<@" + notMuted.join(">, <@") + ">"); + + emb.setTitle("Unmute") + .setDescription("**Reason**\n" + reason) .addField("Unmuted", (success.length > 0 ? "<@" + success.join(">, <@") + ">" : "`[NONE]`")); if (cant.length > 0) emb.addField("Can't unmute", "<@" + cant.join(">, <@") + ">"); - if (notMuted.length > 0) emb.addField("Wasn't muted", "<@" + notMuted.join(">, <@") + ">"); return trySend(msg.client, msg, { content: resultMsg, embed: emb }); } } \ No newline at end of file diff --git a/resources/structures.js b/resources/structures.js index 623bb4d..ade8a33 100644 --- a/resources/structures.js +++ b/resources/structures.js @@ -202,8 +202,8 @@ Structures.extend("User", u => { const MEM = guild.member(this); const CL = guild.member(this.client.user); - if (!CL.hasPermission("MANAGE_ROLES") || - !data.moderator.hasPermission("MANAGE_ROLES")) throw new Error("Missing Permissions"); + if (!(CL.isAdmin || CL.hasPermission("MANAGE_ROLES")) || + !(data.moderator.idAdmin || data.moderator.hasPermission("MANAGE_ROLES"))) throw new Error("Missing Permissions"); if (MEM) { if (data.moderator.roles.highest.position < MEM.roles.highest.position || MEM.roles.highest.position > guild.member(this.client.user).roles.highest.position) throw new Error("You can't mute someone with higher position than you <:nekokekLife:852865942530949160>"); @@ -238,8 +238,8 @@ Structures.extend("User", u => { if (!guild || !(guild instanceof Guild)) throw new TypeError("Guild is: " + guild); const MEM = guild.member(this); const CL = guild.member(this.client.user); - if (!CL.hasPermission("MANAGE_ROLES") || - !moderator.hasPermission("MANAGE_ROLES")) throw new Error("Missing Permissions"); + if (!(CL.isAdmin || CL.hasPermission("MANAGE_ROLES")) || + !(moderator.idAdmin || moderator.hasPermission("MANAGE_ROLES"))) throw new Error("Missing Permissions"); if (!guild.DB) await guild.dbLoad(); if (!this.bot) { @@ -272,8 +272,8 @@ Structures.extend("User", u => { if (!data?.infraction) throw new Error("Missing infraction id"); const MEM = guild.member(this); const CL = guild.member(this.client.user); - if (!CL.hasPermission("BAN_MEMBERS") || - !data.moderator.hasPermission("BAN_MEMBERS")) throw new Error("Missing Permissions"); + if (!(CL.isAdmin || CL.hasPermission("BAN_MEMBERS")) || + !(data.moderation.isAdmin || data.moderator.hasPermission("BAN_MEMBERS"))) throw new Error("Missing Permissions"); if (MEM) { if (moderator.roles.highest.position < MEM.roles.highest.position || MEM.roles.highest.position > CL.roles.highest.position)