diff --git a/cmds/moderation/mute.js b/cmds/moderation/mute.js index fcb4fa0..9e04797 100644 --- a/cmds/moderation/mute.js +++ b/cmds/moderation/mute.js @@ -24,55 +24,58 @@ module.exports = class mute extends commando.Command { * @returns */ async run(msg, arg) { - const doc = await col.findOne({document: msg.guild.id}); - const moderationDoc = doc?.["moderation"]; - const infractionDoc = moderationDoc?.infractions; - const args = arg.trim().split(/(? 0) { + timeForMessage.push(`${elapsed[index]} ${elapsedName[index]}`); + } else {} + } + for (let index = 0; index < timeForMessage.length; index++) { + if (parseInt(timeForMessage[index].split(" ")[0], 10) > 1) { + timeForMessage[index] += "s"; + } + } + if (timeForMessage.length > 1) { + timeForMessage[timeForMessage.length - 2] += " and"; + } } for (const usermention of mentions) { if (usermention.length > 0) { - let found = []; - let nameid = usermention.trim(); - nameid = cleanMentionID(nameid); + let found = [], + nameid = cleanMentionID(usermention); if (/^\d{17,19}$/.test(nameid)) { const findmem = msg.guild.member(nameid); if (findmem) { @@ -118,11 +152,12 @@ module.exports = class mute extends commando.Command { } let infractionToDoc; if (targetUser.length > 0) { + const infractionCase = infractionDoc?.map(r => r.infraction)?.length; infractionToDoc = { - infraction: Math.max(infractionDoc?.map(r => r.infraction) + 1), + infraction: infractionCase ? infractionCase + 1 : 1, by: targetUser, moderator: `**${msg.author.tag}** <@${msg.author.id}> (${msg.author.id})`, - punishment: "Mute", + punishment: "**Mute**", at: invokedAt, for: timeForMessage, until: untilDate, @@ -139,7 +174,7 @@ module.exports = class mute extends commando.Command { } } } - resultMsg += `Result:\`\`\`js\nUsers: ${targetUser.map(r => r?.tag).join(", ")}\nReason: ${reason}\nAt: ${invokedAt.toUTCString()}\nFor: ${timeForMessage === "Indefinite" ? timeForMessage : timeForMessage.join(" + ")}\nUntil: ${typeof untilDate !== "string" ? untilDate.toUTCString() : untilDate}\`\`\`\n`; + resultMsg += `Result:\`\`\`js\nUsers: ${targetUser.map(r => r?.tag).join(", ")}\nReason: ${reason}\nAt: ${invokedAt.toUTCString()}\nFor: ${timeForMessage.join(" ")}\nUntil: ${typeof untilDate !== "string" ? untilDate.toUTCString() : untilDate}\`\`\`\n`; trySend(this.client, msg, "```js\n" + JSON.stringify(infractionToDoc, null, 2) + "```"); return trySend(this.client, msg, resultMsg); }