Add last-run file support

This commit is contained in:
Dragon Fire
2021-02-01 21:51:00 -05:00
parent 9d4b525333
commit 50de60cd1f
9 changed files with 117 additions and 3 deletions
+15 -1
View File
@@ -92,13 +92,26 @@ client.on('ready', async () => {
client.logger.error(`[LEADERBOARD] Could not parse command-leaderboard.json:\n${err.stack}`);
}
// Export command-leaderboard.json every 30 minutes
// Export command-last-run.json
try {
const results = client.importLastRun();
if (!results) client.logger.error('[LASTRUN] command-last-run.json is not formatted correctly.');
} catch (err) {
client.logger.error(`[LASTRUN] Could not parse command-last-run.json:\n${err.stack}`);
}
// Export command-leaderboard.json and command-last-run.json every 30 minutes
client.setInterval(() => {
try {
client.exportCommandLeaderboard();
} catch (err) {
client.logger.error(`[LEADERBOARD] Failed to export command-leaderboard.json:\n${err.stack}`);
}
try {
client.exportLastRun();
} catch (err) {
client.logger.error(`[LASTRUN] Failed to export command-last-run.json:\n${err.stack}`);
}
}, 1.8e+6);
});
@@ -178,6 +191,7 @@ client.on('guildMemberRemove', async member => {
client.on('disconnect', event => {
client.logger.error(`[DISCONNECT] Disconnected with code ${event.code}.`);
client.exportCommandLeaderboard();
client.exportLastRun();
process.exit(0);
});