diff --git a/src/Client.js b/src/Client.js index d59cb3307..d2ef0798f 100644 --- a/src/Client.js +++ b/src/Client.js @@ -529,10 +529,12 @@ class Client extends EventsEmitter { }, 6000 * i); if (this.cacheMessages == true || (this.cacheMembers == true && this.cacheAllMembers != true) || this.cacheUsers == true) - setInterval(() => { + setInterval(async () => { const currentTime = Math.floor(new Date().getTime() / 1000); + const currentStorage = await this.storage.all(); + if (this.cacheMessages == true || (this.cacheMembers == true && this.cacheAllMembers != true)) this.guilds.cache.forEach(guild => { @@ -554,9 +556,9 @@ class Client extends EventsEmitter { this.emit("debug", `New cache size of ${nowCached || 0} for CHANNEL ${guild.id}...`); - // const nowStored = await channel.messages.sweepStorage(currentTime); + const nowStored = await channel.messages.sweepStorage(currentTime, currentStorage); - // this.emit("debug", `New storage size of ${nowStored || 0} for CHANNEL ${guild.id}...`); + this.emit("debug", `New storage size of ${nowStored || 0} for CHANNEL ${guild.id}...`); }); diff --git a/src/managers/ChannelMessageManager.js b/src/managers/ChannelMessageManager.js index c1ea1f9c0..018cdb07b 100644 --- a/src/managers/ChannelMessageManager.js +++ b/src/managers/ChannelMessageManager.js @@ -91,9 +91,8 @@ class ChannelMessageManager { } - async sweepStorage(currentTime) { + async sweepStorage(currentTime, currentStorage) { - const currentStorage = await this.storage.all(); const currentStorageSize = currentStorage.length; for (let i = 0, cacheSize = currentStorageSize; i < currentStorageSize; i++) {