diff --git a/bot.js b/bot.js index d55bcbb..3d8c4a0 100644 --- a/bot.js +++ b/bot.js @@ -20,7 +20,8 @@ client.misc = { }, lxp: { enabled: [], - xp: {} + xp: {}, + hasLevelRoles: [] } } }; diff --git a/models/levelroles.js b/models/levelroles.js new file mode 100644 index 0000000..e31f435 --- /dev/null +++ b/models/levelroles.js @@ -0,0 +1,8 @@ +const mongoose = require('mongoose'); + +const LR = new mongoose.Schema({ + gid: {type: String, unique: true}, + roles: {type: Object, default: {}} +}); + +module.exports = mongoose.model('levelroles', LR); \ No newline at end of file diff --git a/util/cache.js b/util/cache.js index 527e735..b892cdb 100644 --- a/util/cache.js +++ b/util/cache.js @@ -18,4 +18,9 @@ module.exports = async (client) => { 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.`)}`); + + let ora_lrCache = ora("Caching Level Roles...").start(); + 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.enabled.length}`)} ${chalk.blueBright(`guilds with Level Roles enabled.`)}`); }; \ No newline at end of file diff --git a/util/cache/lr.js b/util/cache/lr.js new file mode 100644 index 0000000..1b0bb7b --- /dev/null +++ b/util/cache/lr.js @@ -0,0 +1,9 @@ +const LR = require('../../models/levelroles'); + +module.exports = async client => { + client.misc.cache.lxp.hasLevelRoles = []; + + for await (const lr of LR.find()) { + client.misc.cache.lxp.hasLevelRoles.push(lr.gid); + } +}; \ No newline at end of file