cache a reversed lookup list of chars and animes

master
Kit Kasune 3 years ago
parent 9947602f82
commit 712472b059
  1. 4
      bot.js
  2. 2
      util/cache/anime.js
  3. 6
      util/cache/char.js

@ -37,7 +37,9 @@ client.misc = {
VCG: {}, VCG: {},
activeVC: [], activeVC: [],
chars: new Discord.Collection(), chars: new Discord.Collection(),
anime: new Discord.Collection() anime: new Discord.Collection(),
charsID: new Discord.Collection(),
animeID: new Discord.Collection()
}, },
loggers: {}, loggers: {},
rl: readline.createInterface({input: process.stdin, output: process.stdout}) rl: readline.createInterface({input: process.stdin, output: process.stdout})

@ -4,11 +4,13 @@ const AniData = require('../../models/anime');
module.exports = async client => { module.exports = async client => {
client.misc.cache.anime = new Discord.Collection(); client.misc.cache.anime = new Discord.Collection();
client.misc.cache.animeID = new Discord.Collection();
for await (const ani of AniData.find()) { for await (const ani of AniData.find()) {
if (ani.queued !== true) { if (ani.queued !== true) {
client.misc.cache.anime.set(ani.japname, ani.id); client.misc.cache.anime.set(ani.japname, ani.id);
client.misc.cache.anime.set(ani.name, ani.id); client.misc.cache.anime.set(ani.name, ani.id);
client.misc.cache.animeID.set(ani.id, ani.name);
} }
} }
} }

@ -4,8 +4,12 @@ const CharData = require('../../models/char');
module.exports = async client => { module.exports = async client => {
client.misc.cache.chars = new Discord.Collection(); client.misc.cache.chars = new Discord.Collection();
client.misc.cache.charsID = new Discord.Collection();
for await (const char of CharData.find()) { 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);
}
} }
} }
Loading…
Cancel
Save