rapid bugfix

This commit is contained in:
Erik 2022-01-12 18:46:06 +02:00
parent 64095adc1a
commit ed4e4b132c
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589
2 changed files with 12 additions and 5 deletions

View File

@ -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;

View File

@ -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 () {