You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Natsuki/util/cache/monit.js

25 lines
835 B

3 years ago
const Monitor = require('../../models/monitor');
const chalk = require('chalk');
3 years ago
module.exports = async (client, spinner) => {
return new Promise(async resolve => {
client.misc.cache.monit = {};
client.misc.cache.monitEnabled = [];
let amount = 0;
for await (const tm of Monitor.find()) {
client.misc.cache.monit[tm.gid] = {
messages: tm.messages,
voice: tm.voice,
expiry: new Date()
};
client.misc.cache.monitEnabled.push(tm.gid);
spinner.update({text: `${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${amount}`)} ${chalk.blueBright(`guilds with Monitors enabled.`)}`});
amount++;
}
spinner.status('non-spinnable');
resolve(0);
});
3 years ago
}