aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-07-11 00:49:30 -0400
committerRapptz <[email protected]>2019-07-11 00:49:30 -0400
commitbc352f0e502efe2a824914df53267b17b92b0f5d (patch)
tree88d5b741ead2b04ae37023cdd374c4f2c6ed848c
parentUse Guild.owner_id in Guild.edit when checking if the bot owns a guild. (diff)
downloaddiscord.py-bc352f0e502efe2a824914df53267b17b92b0f5d.tar.xz
discord.py-bc352f0e502efe2a824914df53267b17b92b0f5d.zip
Allow complete disabling of the member cache.
-rw-r--r--discord/state.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/discord/state.py b/discord/state.py
index 0b6c564f..91391154 100644
--- a/discord/state.py
+++ b/discord/state.py
@@ -71,6 +71,8 @@ class ConnectionState:
self._fetch_offline = options.get('fetch_offline_members', True)
self.heartbeat_timeout = options.get('heartbeat_timeout', 60.0)
self.guild_subscriptions = options.get('guild_subscriptions', True)
+ # Only disable cache if both fetch_offline and guild_subscriptions are off.
+ self._cache_members = not (self._fetch_offline or self.guild_subscriptions)
self._listeners = []
activity = options.get('activity', None)
@@ -584,7 +586,8 @@ class ConnectionState:
return
member = Member(guild=guild, data=data, state=self)
- guild._add_member(member)
+ if self._cache_members:
+ guild._add_member(member)
guild._member_count += 1
self.dispatch('member_join', member)