Skip to content

Commit

Permalink
Remove archived threads from cache (#2322)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinnDevelopment committed Nov 3, 2022
1 parent 6de17c5 commit 7660750
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import net.dv8tion.jda.internal.JDAImpl;
import net.dv8tion.jda.internal.entities.channel.concrete.ThreadChannelImpl;
import net.dv8tion.jda.internal.utils.Helpers;
import net.dv8tion.jda.internal.utils.cache.SnowflakeCacheViewImpl;
import net.dv8tion.jda.internal.utils.cache.SortedSnowflakeCacheViewImpl;

import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -171,6 +173,14 @@ protected Long handleInternally(DataObject content)
}
}

if (thread.isArchived())
{
SortedSnowflakeCacheViewImpl<ThreadChannel> guildView = thread.getGuild().getThreadChannelsView();
SnowflakeCacheViewImpl<ThreadChannel> globalView = api.getThreadChannelsView();
guildView.remove(threadId);
globalView.remove(threadId);
}

return null;
}
}

0 comments on commit 7660750

Please sign in to comment.