aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorRapptz <[email protected]>2020-09-28 05:12:05 -0400
committerRapptz <[email protected]>2020-09-28 05:12:05 -0400
commit1ebb52b13922bdc8600f398920594f5bddb1a035 (patch)
treefdc5de1bba131faa38f7c6938b5f706ff0a7fb7a /discord
parentUpdate intents with small typo fixes (diff)
downloaddiscord.py-1ebb52b13922bdc8600f398920594f5bddb1a035.tar.xz
discord.py-1ebb52b13922bdc8600f398920594f5bddb1a035.zip
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.
Diffstat (limited to 'discord')
-rw-r--r--discord/state.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/discord/state.py b/discord/state.py
index aec723d4..fa6a9ff3 100644
--- a/discord/state.py
+++ b/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: