monitor caching

master
Kit Kasune 4 years ago
parent 493d61eb1f
commit 64057c3332
  1. 3
      bot.js
  2. 5
      util/cache.js
  3. 12
      util/cache/monit.js

@ -22,7 +22,8 @@ client.misc = {
enabled: [], enabled: [],
xp: {}, xp: {},
hasLevelRoles: [] hasLevelRoles: []
} },
monit: {}
}, },
loggers: {} loggers: {}
}; };

@ -23,4 +23,9 @@ module.exports = async (client) => {
await require('./cache/lr')(client); await require('./cache/lr')(client);
ora_lrCache.stop(); ora_lrCache.clear(); ora_lrCache.stop(); ora_lrCache.clear();
console.log(`${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${client.misc.cache.lxp.hasLevelRoles.length}`)} ${chalk.blueBright(`guilds with Level Roles enabled.`)}`); console.log(`${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${client.misc.cache.lxp.hasLevelRoles.length}`)} ${chalk.blueBright(`guilds with Level Roles enabled.`)}`);
let ora_lrCache = ora("Caching Monitors...").start();
await require('./cache/monit')(client);
ora_moCache.stop(); ora_moCache.clear();
console.log(`${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${Object.keys(client.misc.cache.monit).length}`)} ${chalk.blueBright(`guilds with Monitors enabled.`)}`);
}; };

@ -0,0 +1,12 @@
const Monitor = require('../../models/monitor');
module.exports = async client => {
client.misc.cache.monit = {};
for await (const tm of Monitor.find()) {
client.misc.cache.monit[tm.gid] = {
messages: tm.messages,
voice: tm.voice
};
}
}
Loading…
Cancel
Save