diff --git a/structure/Modmail.js b/structure/Modmail.js index f4f90c5..ff88cc7 100644 --- a/structure/Modmail.js +++ b/structure/Modmail.js @@ -111,15 +111,8 @@ class Modmail { if (!member) return; // No member object found in main or bans server? const now = Math.floor(Date.now() / 1000); - const lastActivity = this.client.cache.lastActivity[author.id]; - // console.log(now - lastActivity, lastActivity, now) - if (!lastActivity || now - lastActivity > 30 * 60) { - await author.send(`Thank you for your message, we'll get back to you soon!`); - } - this.client.cache.lastActivity[author.id] = now; - - const { cache } = this.client; - + const { cache } = this; + // Anti spam if (!this.spammers[author.id]) this.spammers[author.id] = { start: now, count: 1, timeout: false, warned: false }; else if (this.spammers[author.id].timeout) { @@ -135,6 +128,12 @@ class Modmail { } else if (now - this.spammers[author.id].start > 15) this.spammers[author.id] = { start: now, count: 1, timeout: false, warned: false }; else this.spammers[author.id].count++; + const lastActivity = this.cache.lastActivity[author.id]; + if (!lastActivity || now - lastActivity > 30 * 60) { + await author.send(`Thank you for your message, we'll get back to you soon!`); + } + this.cache.lastActivity[author.id] = now; + if (this.disabled) { let reason = `Modmail has been disabled for the time being`; if (this.disabledReason) reason += ` for the following reason:\n\n${this.disabledReason}`;