From fed7f341bec33b742eda4123fbe2bbd7e9f64654 Mon Sep 17 00:00:00 2001 From: Jacob Morrison Date: Mon, 22 Jan 2024 08:17:23 -0500 Subject: [PATCH] Skip sweeping if the guild is not available (#10070) * Skip sweeping if the guild is not available * Typo * Fix formatting * Fix lint * Check if key in guild * Bwck to guild a ailable --------- Co-authored-by: Jake Morrison Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/src/util/Sweepers.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/discord.js/src/util/Sweepers.js b/packages/discord.js/src/util/Sweepers.js index 3ff81814d..edc328749 100644 --- a/packages/discord.js/src/util/Sweepers.js +++ b/packages/discord.js/src/util/Sweepers.js @@ -425,6 +425,9 @@ class Sweepers { let items = 0; for (const guild of this.client.guilds.cache.values()) { + // We may be unable to sweep the cache if the guild is unavailable and was never patched + if (!guild.available) continue; + const { cache } = guild[key]; guilds++;