From cbc55014a4a274ab786153dcc4fcb7ec88a74cb3 Mon Sep 17 00:00:00 2001 From: gabixdev Date: Tue, 4 Dec 2018 08:21:46 +0100 Subject: [PATCH] Fix bot gateway connection --- litecord/gateway/websocket.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/litecord/gateway/websocket.py b/litecord/gateway/websocket.py index cc99d19..7fa74d3 100644 --- a/litecord/gateway/websocket.py +++ b/litecord/gateway/websocket.py @@ -224,7 +224,7 @@ class GatewayWebsocket: if self.state.bot: return [{ - 'id': row[0], + 'id': row, 'unavailable': True, } for row in guild_ids] @@ -373,12 +373,13 @@ class GatewayWebsocket: log.info('subscribing to {} dms', len(dm_ids)) await self.ext.dispatcher.sub_many('channel', user_id, dm_ids) - # subscribe to all friends - # (their friends will also subscribe back - # when they come online) - friend_ids = await self.user_storage.get_friend_ids(user_id) - log.info('subscribing to {} friends', len(friend_ids)) - await self.ext.dispatcher.sub_many('friend', user_id, friend_ids) + if not self.state.bot: + # subscribe to all friends + # (their friends will also subscribe back + # when they come online) + friend_ids = await self.user_storage.get_friend_ids(user_id) + log.info('subscribing to {} friends', len(friend_ids)) + await self.ext.dispatcher.sub_many('friend', user_id, friend_ids) async def update_status(self, status: dict): """Update the status of the current websocket connection.""" @@ -891,7 +892,6 @@ class GatewayWebsocket: log.warning('conn close, state={}, err={}', self.state, err) except WebsocketClose as err: log.warning('ws close, state={} err={}', self.state, err) - await self.ws.close(code=err.code, reason=err.reason) except Exception as err: log.exception('An exception has occoured. state={}', self.state)