mirror of https://gitlab.com/litecord/litecord.git
storage: add presence fetching on get_guild_extra
This commit is contained in:
parent
3858e20080
commit
14d3149f50
|
|
@ -17,6 +17,7 @@ class Storage:
|
||||||
"""Class for common SQL statements."""
|
"""Class for common SQL statements."""
|
||||||
def __init__(self, db):
|
def __init__(self, db):
|
||||||
self.db = db
|
self.db = db
|
||||||
|
self.presence = None
|
||||||
|
|
||||||
async def get_user(self, user_id, secure=False) -> Dict[str, Any]:
|
async def get_user(self, user_id, secure=False) -> Dict[str, Any]:
|
||||||
"""Get a single user payload."""
|
"""Get a single user payload."""
|
||||||
|
|
@ -307,6 +308,8 @@ class Storage:
|
||||||
channels = await self.get_channel_data(guild_id)
|
channels = await self.get_channel_data(guild_id)
|
||||||
roles = await self.get_role_data(guild_id)
|
roles = await self.get_role_data(guild_id)
|
||||||
|
|
||||||
|
mids = [int(m['user']['id']) for m in members]
|
||||||
|
|
||||||
return {**res, **{
|
return {**res, **{
|
||||||
'member_count': member_count,
|
'member_count': member_count,
|
||||||
'members': members,
|
'members': members,
|
||||||
|
|
@ -314,8 +317,9 @@ class Storage:
|
||||||
'channels': channels,
|
'channels': channels,
|
||||||
'roles': roles,
|
'roles': roles,
|
||||||
|
|
||||||
# TODO: finish presences
|
'presences': await self.presence.guild_presences(
|
||||||
'presences': [],
|
mids, guild_id
|
||||||
|
),
|
||||||
}}
|
}}
|
||||||
|
|
||||||
async def _msg_regex(self, regex, method, content) -> List[Dict]:
|
async def _msg_regex(self, regex, method, content) -> List[Dict]:
|
||||||
|
|
|
||||||
2
run.py
2
run.py
|
|
@ -87,9 +87,11 @@ async def app_before_serving():
|
||||||
|
|
||||||
app.state_manager = StateManager()
|
app.state_manager = StateManager()
|
||||||
app.dispatcher = EventDispatcher(app.state_manager)
|
app.dispatcher = EventDispatcher(app.state_manager)
|
||||||
|
|
||||||
app.storage = Storage(app.db)
|
app.storage = Storage(app.db)
|
||||||
app.presence = PresenceManager(app.storage,
|
app.presence = PresenceManager(app.storage,
|
||||||
app.state_manager, app.dispatcher)
|
app.state_manager, app.dispatcher)
|
||||||
|
app.storage.presence = app.presence
|
||||||
|
|
||||||
# start the websocket, etc
|
# start the websocket, etc
|
||||||
host, port = app.config['WS_HOST'], app.config['WS_PORT']
|
host, port = app.config['WS_HOST'], app.config['WS_PORT']
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue