diff --git a/bot.js b/bot.js index 1d6b0ce..b095501 100644 --- a/bot.js +++ b/bot.js @@ -35,7 +35,9 @@ client.misc = { monitEnabled: [], inVC: [], VCG: {}, - activeVC: [] + activeVC: [], + chars: new Discord.Collection(), + anime: new Discord.Collection() }, loggers: {}, rl: readline.createInterface({input: process.stdin, output: process.stdout}) diff --git a/util/cache.js b/util/cache.js index b22abd6..0b1c67c 100644 --- a/util/cache.js +++ b/util/cache.js @@ -28,4 +28,14 @@ module.exports = async (client) => { 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.`)}`); + + let ora_anCache = ora("Caching Animes...").start(); + await require('./cache/anime')(client); + ora_anCache.stop(); ora_anCache.clear(); + console.log(`${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${client.misc.cache.anime.size / 2}`)} ${chalk.blueBright(`animes into lookup registry.`)}`); + + let ora_chCache = ora("Caching Characters...").start(); + await require('./cache/char')(client); + ora_chCache.stop(); ora_chCache.clear(); + console.log(`${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${client.misc.cache.chars.size}`)} ${chalk.blueBright(`characters into lookup registry.`)}`); }; \ No newline at end of file diff --git a/util/cache/anime.js b/util/cache/anime.js new file mode 100644 index 0000000..d54a4b0 --- /dev/null +++ b/util/cache/anime.js @@ -0,0 +1,12 @@ +const Discord = require('discord.js'); + +const AniData = require('../../models/anime'); + +module.exports = async client => { + client.misc.cache.anime = new Discord.Collection(); + + for await (const ani of AniData.find()) { + client.misc.cache.anime.set(ani.japname, ani.id); + client.misc.cache.anime.set(ani.name, ani.id); + } +} \ No newline at end of file diff --git a/util/cache/char.js b/util/cache/char.js new file mode 100644 index 0000000..bfd2df9 --- /dev/null +++ b/util/cache/char.js @@ -0,0 +1,11 @@ +const Discord = require('discord.js'); + +const CharData = require('../../models/char'); + +module.exports = async client => { + client.misc.cache.chars = new Discord.Collection(); + + for await (const char of CharData.find()) { + client.misc.cache.chars.set(char.name, char.id); + } +} \ No newline at end of file