mirror of https://gitlab.com/litecord/litecord.git
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:
parent
30d9520935
commit
899f19b24c
|
|
@ -670,7 +670,7 @@ class GatewayWebsocket:
|
||||||
voice_state = await self.ext.voice.get_state(voice_key)
|
voice_state = await self.ext.voice.get_state(voice_key)
|
||||||
|
|
||||||
if voice_state is None:
|
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_guild = guild_id == voice_state.guild_id
|
||||||
same_channel = channel_id == voice_state.channel_id
|
same_channel = channel_id == voice_state.channel_id
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ class LVSPManager:
|
||||||
|
|
||||||
return conn.health
|
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
|
"""Get a voice server for the given guild, assigns
|
||||||
one if there isn't any"""
|
one if there isn't any"""
|
||||||
|
|
||||||
|
|
@ -131,10 +131,13 @@ class LVSPManager:
|
||||||
# sort connected servers by health
|
# sort connected servers by health
|
||||||
sorted_servers = sorted(
|
sorted_servers = sorted(
|
||||||
self.servers[region],
|
self.servers[region],
|
||||||
self.get_health,
|
key=self.get_health
|
||||||
)
|
)
|
||||||
|
|
||||||
hostname = sorted_servers[0]
|
try:
|
||||||
|
hostname = sorted_servers[0]
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
|
||||||
return hostname
|
return hostname
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,10 @@ class VoiceManager:
|
||||||
|
|
||||||
async def _lvsp_info_guild(self, guild_id, info_type, info_data):
|
async def _lvsp_info_guild(self, guild_id, info_type, info_data):
|
||||||
hostname = await self.lvsp.get_guild_server(guild_id)
|
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)
|
conn = self.lvsp.get_conn(hostname)
|
||||||
await conn.send_info(info_type, info_data)
|
await conn.send_info(info_type, info_data)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue