Browse Source

Guard GUILD_MEMBER_ADD/GUILD_MEMBER_REMOVE from errors

If the guilds intent is disabled all guilds are unavailable. This means
we don't receive a member_count attribute and cannot update it.
pull/5870/head
Rapptz 5 years ago
parent
commit
1ebb52b139
  1. 13
      discord/state.py

13
discord/state.py

@ -731,13 +731,22 @@ class ConnectionState:
member = Member(guild=guild, data=data, state=self)
if self._member_cache_flags.joined:
guild._add_member(member)
guild._member_count += 1
try:
guild._member_count += 1
except AttributeError:
pass
self.dispatch('member_join', member)
def parse_guild_member_remove(self, data):
guild = self._get_guild(int(data['guild_id']))
if guild is not None:
guild._member_count -= 1
try:
guild._member_count -= 1
except AttributeError:
pass
user_id = int(data['user']['id'])
member = guild.get_member(user_id)
if member is not None:

Loading…
Cancel
Save