FIX TO DUMB ISSUE LOL
This commit is contained in:
parent
2a9218e7f3
commit
60505a6a75
@ -57,7 +57,11 @@ class ModmailClient extends Client {
|
||||
this.modmail.init();
|
||||
|
||||
process.on('exit', this.saveCache.bind(this));
|
||||
process.on('SIGINT', this.saveCache.bind(this));
|
||||
process.on('SIGINT', () => {
|
||||
this.saveCache.bind(this);
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit();
|
||||
});
|
||||
|
||||
this._ready = true;
|
||||
|
||||
|
@ -510,7 +510,10 @@ class Modmail {
|
||||
if (this.mmcache[userId]) return resolve(this.mmcache[userId]);
|
||||
|
||||
const path = `./modmail_cache/${userId}.json`;
|
||||
if (!fs.existsSync(path)) return resolve([]);
|
||||
if (!fs.existsSync(path)) {
|
||||
this.mmcache[userId] = [];
|
||||
return resolve(this.mmcache[userId]);
|
||||
}
|
||||
|
||||
fs.readFile(path, { encoding: 'utf-8' }, (err, data) => {
|
||||
if (err) reject(err);
|
||||
@ -532,7 +535,11 @@ class Modmail {
|
||||
|
||||
for (const id of toSave) {
|
||||
const path = `./modmail_cache/${id}.json`;
|
||||
try {
|
||||
fs.writeFileSync(path, JSON.stringify(this.mmcache[id]));
|
||||
} catch (err) {
|
||||
this.client.logger.error(`Error during saving of history\n${id}\n${JSON.stringify(this.mmcache)}\n${err.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user