diff --git a/bot.js b/bot.js index b74f905..6b0be67 100644 --- a/bot.js +++ b/bot.js @@ -22,7 +22,8 @@ client.misc = { enabled: [], xp: {}, hasLevelRoles: [] - } + }, + monit: {} }, loggers: {} }; diff --git a/util/cache.js b/util/cache.js index 19c959c..536c310 100644 --- a/util/cache.js +++ b/util/cache.js @@ -23,4 +23,9 @@ module.exports = async (client) => { await require('./cache/lr')(client); 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.`)}`); + + 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.`)}`); }; \ No newline at end of file diff --git a/util/cache/monit.js b/util/cache/monit.js new file mode 100644 index 0000000..8610de1 --- /dev/null +++ b/util/cache/monit.js @@ -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 + }; + } +} \ No newline at end of file