storage: rewrite the guild object as unavailable

more at https://discordapp.com/developers/docs/resources/guild#unavailable-guild-object
This commit is contained in:
Luna 2019-04-21 23:07:05 -03:00
parent bb6055f009
commit ea9b06182d
1 changed files with 10 additions and 2 deletions

View File

@ -192,11 +192,16 @@ class Storage:
drow['max_presences'] = 1000 drow['max_presences'] = 1000
drow['max_members'] = 1000 drow['max_members'] = 1000
# this is kept in memory # a guild's unavailable state is kept in memory, and we remove every
# other guild related field when its unavailable.
drow['unavailable'] = self.app.guild_store.get( drow['unavailable'] = self.app.guild_store.get(
guild_id, 'unavailable', False) guild_id, 'unavailable', False)
# TODO: strip everything when unavailable if drow['unavailable']:
drow = {
'id': drow['id'],
'unavailable': True
}
return drow return drow
@ -669,6 +674,9 @@ class Storage:
if guild is None: if guild is None:
return None return None
if guild['unavailable']:
return guild
extra = await self.get_guild_extra(guild_id, user_id, large_count) extra = await self.get_guild_extra(guild_id, user_id, large_count)
return {**guild, **extra} return {**guild, **extra}