From 8416d73ce5e9240e6bd31b1286c837eb37c2b0b8 Mon Sep 17 00:00:00 2001 From: Carol Knieriem Date: Tue, 4 Feb 2020 09:35:45 -0500 Subject: [PATCH] Update functions.js --- modules/functions.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/functions.js b/modules/functions.js index 4d75bb5..901dffa 100644 --- a/modules/functions.js +++ b/modules/functions.js @@ -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;