gateway.websocket: fix some errors

right now requesting a voice channel won't return ANY voice events back
to the client, causing a visual/behavioral "lock" on the official
client, since there isn't any available voice servers.
This commit is contained in:
Luna 2019-03-05 01:35:17 -03:00
parent 30d9520935
commit 899f19b24c
3 changed files with 11 additions and 4 deletions

View File

@ -670,7 +670,7 @@ class GatewayWebsocket:
voice_state = await self.ext.voice.get_state(voice_key)
if voice_state is None:
return await self.ext.voice.create_state(voice_key)
return await self.ext.voice.create_state(voice_key, data)
same_guild = guild_id == voice_state.guild_id
same_channel = channel_id == voice_state.channel_id

View File

@ -119,7 +119,7 @@ class LVSPManager:
return conn.health
async def get_guild_server(self, guild_id: int) -> str:
async def get_guild_server(self, guild_id: int) -> Optional[str]:
"""Get a voice server for the given guild, assigns
one if there isn't any"""
@ -131,10 +131,13 @@ class LVSPManager:
# sort connected servers by health
sorted_servers = sorted(
self.servers[region],
self.get_health,
key=self.get_health
)
try:
hostname = sorted_servers[0]
except IndexError:
return None
return hostname

View File

@ -157,6 +157,10 @@ class VoiceManager:
async def _lvsp_info_guild(self, guild_id, info_type, info_data):
hostname = await self.lvsp.get_guild_server(guild_id)
if hostname is None:
log.error('no voice server for guild id {}', guild_id)
return
conn = self.lvsp.get_conn(hostname)
await conn.send_info(info_type, info_data)