Skip to content

Left guilds remain in the cache during sharding reconnection #11546

Description

@vakiliner

Which package is this bug report for?

discord.js

Issue description

During sharding reconnection, if the bot leaves the guild, the guild will remain in the cache when the session is resumed.
I discovered this bug back on February 27, 2026, but because I was using my library, I only fixed this bug for myself.

Steps:

  1. Wait for the ClientReady event
  2. Turn off the Internet
  3. Remove the app from the guild
  4. Turn on the Internet
  5. Wait for the ClientReady event

Code sample

client.on(Events.ClientReady, (client) => {
    console.log(`Ready. ${client.guilds.cache.size} guilds`)
})
client.on(Events.GuildCreate, (guild) => {
    console.log(`Guild create ${guild.name}`)
})
client.on(Events.GuildDelete, (guild) => {
    console.log(`Guild delete ${guild.name}`)
})

Versions

Nodejs v24.15.0
Discord.js dev, see below

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds

I have tested this issue on a development release

3d61215

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions