Create reason.js

This commit is contained in:
Carol Knieriem 2020-02-04 10:12:04 -05:00
parent b86e0b17d6
commit cccdc5f07f
No known key found for this signature in database
GPG Key ID: 932EC6A6BAEE122B
1 changed files with 46 additions and 0 deletions

View File

@ -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} <reason>.`, 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 <caseID> <reason>"
}