From 712472b05902a2c1107ffc3bb6ac6981d2c39422 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Mon, 20 Dec 2021 14:55:27 -0700 Subject: [PATCH] cache a reversed lookup list of chars and animes --- bot.js | 4 +++- util/cache/anime.js | 2 ++ util/cache/char.js | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bot.js b/bot.js index b095501..64c0a73 100644 --- a/bot.js +++ b/bot.js @@ -37,7 +37,9 @@ client.misc = { VCG: {}, activeVC: [], chars: new Discord.Collection(), - anime: new Discord.Collection() + anime: new Discord.Collection(), + charsID: new Discord.Collection(), + animeID: new Discord.Collection() }, loggers: {}, rl: readline.createInterface({input: process.stdin, output: process.stdout}) diff --git a/util/cache/anime.js b/util/cache/anime.js index 629b113..ce28164 100644 --- a/util/cache/anime.js +++ b/util/cache/anime.js @@ -4,11 +4,13 @@ const AniData = require('../../models/anime'); module.exports = async client => { client.misc.cache.anime = new Discord.Collection(); + client.misc.cache.animeID = new Discord.Collection(); for await (const ani of AniData.find()) { if (ani.queued !== true) { client.misc.cache.anime.set(ani.japname, ani.id); client.misc.cache.anime.set(ani.name, ani.id); + client.misc.cache.animeID.set(ani.id, ani.name); } } } \ No newline at end of file diff --git a/util/cache/char.js b/util/cache/char.js index bb0b09d..c9ea407 100644 --- a/util/cache/char.js +++ b/util/cache/char.js @@ -4,8 +4,12 @@ const CharData = require('../../models/char'); module.exports = async client => { client.misc.cache.chars = new Discord.Collection(); + client.misc.cache.charsID = new Discord.Collection(); for await (const char of CharData.find()) { - if (char.queued !== true) {client.misc.cache.chars.set(char.name, char.id);} + if (char.queued !== true) { + client.misc.cache.chars.set(char.name, char.id); + client.misc.cache.charsID.set(char.id, char.name); + } } } \ No newline at end of file