Create reason.js
This commit is contained in:
parent
b86e0b17d6
commit
cccdc5f07f
1 changed files with 46 additions and 0 deletions
46
commands/Moderation/reason.js
Normal file
46
commands/Moderation/reason.js
Normal 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>"
|
||||
}
|
Loading…
Reference in a new issue