Local XP cache

master
Kit Kasune 4 years ago
parent 85b16f8ad7
commit dbbcf9a051
  1. 4
      bot.js
  2. 5
      util/cache.js
  3. 9
      util/cache/lxp.js

@ -17,6 +17,10 @@ client.misc = {
bl: {
guild: [],
user: []
},
lxp: {
enabled: [],
xp: {}
}
}
};

@ -13,4 +13,9 @@ module.exports = async (client) => {
ora_blCache.stop(); ora_blCache.clear();
console.log(`${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${client.misc.cache.bl.guild.length}`)} ${chalk.blueBright(`guild blacklists`)}`);
console.log(`${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${client.misc.cache.bl.user.length}`)} ${chalk.blueBright(`user blacklists`)}`);
let ora_lxpCache = ora("Caching Local XPs...").start();
await require('./cache/lxp')(client);
ora_lxpCache.stop(); ora_lxpCache.clear();
console.log(`${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${client.misc.cache.lxp.enabled.length}`)} ${chalk.blueBright(`guilds with XP enabled.`)}`);
};

9
util/cache/lxp.js vendored

@ -0,0 +1,9 @@
const LXP = require('../../models/localxp');
module.exports = async client => {
client.misc.cache.lxp.enabled = [];
for await (const xp of LXP.find()) {
client.misc.cache.lxp.enabled.push(xp.gid);
}
};
Loading…
Cancel
Save