Update functions.js

This commit is contained in:
Carol Knieriem 2020-02-04 09:35:45 -05:00
parent a7b3db89e6
commit 8416d73ce5
No known key found for this signature in database
GPG key ID: 932EC6A6BAEE122B

View file

@ -48,6 +48,21 @@ module.exports = (client) => {
}
};
client.caseNumber = async (client, modlog) {
const messages = await modlog.fetchMessages({limit:5});
const log = 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')
).first();
if (!log) return 1;
const thisCase = /Case\s(\d+)/.exec(log.embeds[0].footer.text);
return thisCase ? parseInt(thisCase[1]) + 1 : 1;
};
client.clean = async (client, text) => {
if (text && text.constructor.name == "Promise")
text = await text;