mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 00:40:07 +00:00
better guild & channel dispatch
This commit is contained in:
19
src/cache.ts
19
src/cache.ts
@@ -53,23 +53,18 @@ function memberSweeper(member: DiscordenoMember) {
|
||||
return member.cachedAt - Date.now() < 1800000;
|
||||
}
|
||||
|
||||
export function guildSweeper(guild: DiscordenoGuild) {
|
||||
if (cache.activeGuildIds.has(guild.id)) return false;
|
||||
|
||||
// This is inactive guild. Not a single thing has happened for atleast 30 minutes.
|
||||
// Not a reaction, not a message, not any event!
|
||||
cache.dispatchedGuildIds.add(guild.id);
|
||||
|
||||
// Remove all channel if they were dispatched
|
||||
cache.channels.forEach((channel) => {
|
||||
if (!cache.dispatchedGuildIds.has(channel.guildId)) return;
|
||||
function guildSweeper(guild: DiscordenoGuild) {
|
||||
// Reset activity for next interval
|
||||
if (!cache.activeGuildIds.delete(guild.id)) return false;
|
||||
|
||||
guild.channels.forEach((channel) => {
|
||||
cache.channels.delete(channel.id);
|
||||
cache.dispatchedChannelIds.add(channel.id);
|
||||
});
|
||||
|
||||
// Reset activity for next interval
|
||||
cache.activeGuildIds.delete(guild.id);
|
||||
// This is inactive guild. Not a single thing has happened for atleast 30 minutes.
|
||||
// Not a reaction, not a message, not any event!
|
||||
cache.dispatchedGuildIds.add(guild.id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user