Browse Source

Fix Template.source_guild attempting to get from cache

pull/9540/head
cibere 2 years ago
committed by GitHub
parent
commit
16f6466da1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      discord/template.py

21
discord/template.py

@ -69,6 +69,10 @@ class _PartialTemplateState:
def member_cache_flags(self):
return self.__state.member_cache_flags
@property
def cache_guild_expressions(self):
return False
def store_emoji(self, guild, packet) -> None:
return None
@ -146,18 +150,11 @@ class Template:
self.created_at: Optional[datetime.datetime] = parse_time(data.get('created_at'))
self.updated_at: Optional[datetime.datetime] = parse_time(data.get('updated_at'))
guild_id = int(data['source_guild_id'])
guild: Optional[Guild] = self._state._get_guild(guild_id)
self.source_guild: Guild
if guild is None:
source_serialised = data['serialized_source_guild']
source_serialised['id'] = guild_id
state = _PartialTemplateState(state=self._state)
# Guild expects a ConnectionState, we're passing a _PartialTemplateState
self.source_guild = Guild(data=source_serialised, state=state) # type: ignore
else:
self.source_guild = guild
source_serialised = data['serialized_source_guild']
source_serialised['id'] = int(data['source_guild_id'])
state = _PartialTemplateState(state=self._state)
# Guild expects a ConnectionState, we're passing a _PartialTemplateState
self.source_guild = Guild(data=source_serialised, state=state) # type: ignore
self.is_dirty: Optional[bool] = data.get('is_dirty', None)

Loading…
Cancel
Save