From bbddbc4956c6ee3046a38438db3b42b032f1921d Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 27 Dec 2019 23:30:47 +0000 Subject: [PATCH] member_count tracking (#165) * member_count tracking * Remove unset checks. --- disco/state.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/disco/state.py b/disco/state.py index bb6b60d..0aa8888 100644 --- a/disco/state.py +++ b/disco/state.py @@ -285,6 +285,10 @@ class State(object): if event.member.guild_id not in self.guilds: return + # Avoid adding duplicate events to member_count. + if event.member.id not in self.guilds[event.member.guild_id].members: + self.guilds[event.member.guild_id].member_count += 1 + self.guilds[event.member.guild_id].members[event.member.id] = event.member def on_guild_member_update(self, event): @@ -303,6 +307,8 @@ class State(object): if event.user.id not in self.guilds[event.guild_id].members: return + self.guilds[event.guild_id].member_count -= 1 + del self.guilds[event.guild_id].members[event.user.id] def on_guild_members_chunk(self, event):