diff --git a/src/main/java/net/dv8tion/jda/internal/handle/GuildDeleteHandler.java b/src/main/java/net/dv8tion/jda/internal/handle/GuildDeleteHandler.java index 1d2b188ac0..bd1f47a56e 100644 --- a/src/main/java/net/dv8tion/jda/internal/handle/GuildDeleteHandler.java +++ b/src/main/java/net/dv8tion/jda/internal/handle/GuildDeleteHandler.java @@ -64,11 +64,20 @@ protected Long handleInternally(DataObject content) //Remove everything from global cache // this prevents some race-conditions for getting audio managers from guilds SnowflakeCacheViewImpl guildView = getJDA().getGuildsView(); + SnowflakeCacheViewImpl stageView = getJDA().getStageChannelView(); SnowflakeCacheViewImpl storeView = getJDA().getStoreChannelsView(); SnowflakeCacheViewImpl textView = getJDA().getTextChannelsView(); + SnowflakeCacheViewImpl threadView = getJDA().getThreadChannelsView(); + SnowflakeCacheViewImpl newsView = getJDA().getNewsChannelView(); SnowflakeCacheViewImpl voiceView = getJDA().getVoiceChannelsView(); SnowflakeCacheViewImpl categoryView = getJDA().getCategoriesView(); + guildView.remove(id); + try (UnlockHook hook = stageView.writeLock()) + { + guild.getStageChannelCache() + .forEachUnordered(chan -> stageView.getMap().remove(chan.getIdLong())); + } try (UnlockHook hook = storeView.writeLock()) { guild.getStoreChannelCache() @@ -79,6 +88,16 @@ protected Long handleInternally(DataObject content) guild.getTextChannelCache() .forEachUnordered(chan -> textView.getMap().remove(chan.getIdLong())); } + try (UnlockHook hook = threadView.writeLock()) + { + guild.getThreadChannelsView() + .forEachUnordered(chan -> threadView.getMap().remove(chan.getIdLong())); + } + try (UnlockHook hook = newsView.writeLock()) + { + guild.getNewsChannelCache() + .forEachUnordered(chan -> newsView.getMap().remove(chan.getIdLong())); + } try (UnlockHook hook = voiceView.writeLock()) { guild.getVoiceChannelCache()