|
|
@ -748,15 +748,14 @@ class ConnectionState: |
|
|
|
if len(self._interactions) > 15: |
|
|
|
self._interactions.popitem(last=False) |
|
|
|
|
|
|
|
def store_user(self, data: Union[UserPayload, PartialUserPayload]) -> User: |
|
|
|
def store_user(self, data: Union[UserPayload, PartialUserPayload], *, cache: bool = True) -> User: |
|
|
|
# this way is 300% faster than `dict.setdefault`. |
|
|
|
user_id = int(data['id']) |
|
|
|
try: |
|
|
|
return self._users[user_id] |
|
|
|
except KeyError: |
|
|
|
user = User(state=self, data=data) |
|
|
|
# TODO: with the removal of discrims this becomes a bit annoying |
|
|
|
if user.discriminator != '0000': |
|
|
|
if cache: |
|
|
|
self._users[user_id] = user |
|
|
|
return user |
|
|
|
|
|
|
|