From ed4e4b132cb8376891f01374198355e36049e419 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Wed, 12 Jan 2022 18:46:06 +0200 Subject: [PATCH] rapid bugfix --- structure/Client.js | 2 +- structure/JsonCache.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/structure/Client.js b/structure/Client.js index b286389..cd94014 100644 --- a/structure/Client.js +++ b/structure/Client.js @@ -64,7 +64,7 @@ class ModmailClient extends Client { }); process.on('unhandledRejection', (reason, prom) => { - this.logger.error(`Unhandled promise rejection at: ${prom}\nReason: ${reason}`); + this.logger.error(`Unhandled promise rejection at: ${inspect(prom)}\nReason: ${reason}`); }); this._ready = true; diff --git a/structure/JsonCache.js b/structure/JsonCache.js index 2e71938..9f2763a 100644 --- a/structure/JsonCache.js +++ b/structure/JsonCache.js @@ -92,9 +92,11 @@ class JsonCache extends CacheHandler { } - verifyQueue () { + async verifyQueue () { + this.client.logger.info(`Verifying modmail queue.`); - this.queue.forEach(async entry => { + + for (const entry of this.queue) { const path = `./modmail_cache/${entry}.json`; if (fs.existsSync(path)) return; @@ -105,11 +107,16 @@ class JsonCache extends CacheHandler { messages = messages.filter(msg => msg.author.id !== this.client.user.id).sort((a, b) => a.createdTimestamp - b.createdTimestamp); const history = await this.loadModmailHistory(entry); - for (const { author, content, createdTimestamp, attachments } of messages) history.push({ attachments: attachments.map(att => att.url), author: author.id, content, timestamp: createdTimestamp }); + for (const { author, content, createdTimestamp, attachments } of messages.values()) { + history.push({ attachments: attachments.map(att => att.url), author: author.id, content, timestamp: createdTimestamp }); + } + this.updatedThreads.push(entry); - }); + } this.client.logger.info(`Queue verified.`); + this.saveModmailHistory(); + } get json () {