diff --git a/commands/Moderation/reason.js b/commands/Moderation/reason.js new file mode 100644 index 0000000..e2599f1 --- /dev/null +++ b/commands/Moderation/reason.js @@ -0,0 +1,46 @@ +async function embedSan(embed) { + embed.message ? delete embed.message : null; + embed.footer ? delete embed.footer.embed : null; + embed.provider ? delete embed.provider.embed : null; + embed.thumbnail ? delete embed.thumbnail.embed : null; + embed.image ? delete embed.image.embed : null; + embed.author ? delete embed.author.embed : null; + embed.fields ? embed.fields.forEach(f => {delete f.embed;}) : null; + return embed; +} + +exports.run = async (client, message, args, level) => { + const modlog = client.channels.find('name', config.modLogChannel); + const caseNumber = args.shift(); + const newReason = args.join(' '); + + await modlog.fetchMessages({limit:100}).then((messages) => { + const caseLog = messages.filter(m => m.author.id === client.user.id && + m.embeds[0] && + m.embeds[0].type === 'rich' && + m.embeds[0].footer && + m.embeds[0].footer.text.startsWith('Case') && + m.embeds[0].footer.text === `Case ${caseNumber}` + ).first(); + modlog.fetchMessage(caseLog.id).then(logMsg => { + const embed = logMsg.embeds[0]; + embedSan(embed); + embed.description = embed.description.replace(`Awaiting moderator's input. Use ${settings.prefix}reason ${caseNumber} .`, newReason); + logMsg.edit({embed}); + }); + }); +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "Administrator" +}; + +exports.help = { + name: "reason", + category: "Moderation", + description: "Modify the reason for a cited punishment.", + usage: "reason " +} \ No newline at end of file