Browse Source

Don't store a user cache if there's no member intent or cache is off

Without a cache or member intent the user cache can get out of date
with no events to update the underlying user in the member object.

Ref: #6034
pull/6090/head
Rapptz 4 years ago
parent
commit
7a3a571e0a
  1. 4
      discord/flags.py
  2. 6
      discord/state.py

4
discord/flags.py

@ -851,6 +851,10 @@ class MemberCacheFlags(BaseFlags):
self.value = self.DEFAULT_VALUE
return self
@property
def _empty(self):
return self.value == self.DEFAULT_VALUE
@flag_value
def online(self):
""":class:`bool`: Whether to cache members with a status.

6
discord/state.py

@ -186,6 +186,9 @@ class ConnectionState:
self._status = status
self._intents = intents
if not intents.members or cache_flags._empty:
self.store_user = self.store_user_no_intents
self.parsers = parsers = {}
for attr, func in inspect.getmembers(self):
if attr.startswith('parse_'):
@ -279,6 +282,9 @@ class ConnectionState:
self._users[user_id] = user
return user
def store_user_no_intents(self, data):
return User(state=self, data=data)
def get_user(self, id):
return self._users.get(id)

Loading…
Cancel
Save