From 2452ef62d5deac6280840d209fbedc032e5c6807 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Mon, 20 Dec 2021 03:29:31 -0700 Subject: [PATCH] cache fixes --- commands/anime/anime.js | 6 +++++- commands/anime/char.js | 9 ++++++--- util/cache/anime.js | 6 ++++-- util/cache/char.js | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/commands/anime/anime.js b/commands/anime/anime.js index 9b15ecc..0837532 100644 --- a/commands/anime/anime.js +++ b/commands/anime/anime.js @@ -163,7 +163,11 @@ module.exports = { rc.on("collect", async r => { if (r.emoji.name !== '👎') { while (true) {options.id = require('../../util/makeid')(4); if (!await AniData.findOne({id: options.id})) {break;}} - if (!queue) {amEmbed.addField("Reviewed", `Reviewed and submitted by <@${message.author.id}>`);} + if (!queue) { + amEmbed.addField("Reviewed", `Reviewed and submitted by <@${message.author.id}>`); + client.misc.cache.anime.set(options.name, options.id); + client.misc.cache.anime.set(options.japname, options.id); + } else {amEmbed.addField("ID", options.id);} amEmbed.setAuthor(!queue ? "Anime Added" : "Anime Submitted", message.author.avatarURL()); client.guilds.fetch('762707532417335296').then(g => g.channels.cache.get('817466729293938698').send({embeds: [amEmbed]})); diff --git a/commands/anime/char.js b/commands/anime/char.js index 772e339..b8dbaaf 100644 --- a/commands/anime/char.js +++ b/commands/anime/char.js @@ -159,11 +159,13 @@ module.exports = { let rc = am.createReactionCollector({filter: (r, u) => ['👍', '👎'].includes(r.emoji.name) && u.id === message.author.id, max: 1, time: 60000}); rc.on("collect", async r => { if (r.emoji.name !== '👎') { - client.guilds.fetch('762707532417335296').then(g => g.channels.cache.get('817466729293938698').send({embeds: [amEmbed]})); - if (!queue) {amEmbed.addField("Reviewed", `Reviewed and submitted by <@${message.author.id}>`);} + while (true) {options.id = require('../../util/makeid')(4); if (!await Char.findOne({id: options.id})) {break;}} + if (!queue) { + amEmbed.addField("Reviewed", `Reviewed and submitted by <@${message.author.id}>`); + client.misc.cache.chars.set(options.name, options.id); + } else {amEmbed.addField("ID", options.id);} amEmbed.setAuthor(!queue ? "Character Added" : "Character Submitted", message.author.avatarURL()); - while (true) {options.id = require('../../util/makeid')(4); if (!await Char.findOne({id: options.id})) {break;}} if (!queue) {options.queued = false;} await new Char(options).save(); if (aniData) { @@ -171,6 +173,7 @@ module.exports = { aniData.markModified('characters'); aniData.save(); } + client.guilds.fetch('762707532417335296').then(g => g.channels.cache.get('817466729293938698').send({embeds: [amEmbed]})); return message.author.send(`Your character has been ${!queue ? "added" : "submitted"}`); } else { return message.author.send("Oh, okay. I'll discard that then!"); diff --git a/util/cache/anime.js b/util/cache/anime.js index d54a4b0..629b113 100644 --- a/util/cache/anime.js +++ b/util/cache/anime.js @@ -6,7 +6,9 @@ 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); + if (ani.queued !== true) { + 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 index bfd2df9..bb0b09d 100644 --- a/util/cache/char.js +++ b/util/cache/char.js @@ -6,6 +6,6 @@ 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); + if (char.queued !== true) {client.misc.cache.chars.set(char.name, char.id);} } } \ No newline at end of file