Don't connect if synth message from user from another voice channel, fix q drop

This commit is contained in:
norohind 2022-05-22 22:27:32 +03:00
parent c84831aac2
commit bce9abd10a
Signed by: norohind
GPG Key ID: 01C3BECC26FB59E1

View File

@ -85,6 +85,10 @@ class TTSCore(commands.Cog, Observ.Observer):
if voice_client is None:
voice_client: discord.VoiceClient = await user_voice_state.channel.connect()
if user_voice_state.channel.id != voice_client.channel.id:
await message.channel.send('We are in different voice channels')
return
speaker: Speakers = self.speakers_adapter.get_speaker(message.guild.id, message.author.id)
# check if message will fail on synthesis
@ -123,6 +127,9 @@ class TTSCore(commands.Cog, Observ.Observer):
def queue_player(self, message: discord.Message):
for sound_source in self.tts_queues[message.guild.id]:
if len(self.tts_queues[message.guild.id]) == 0:
return
voice_client: Optional[discord.VoiceClient] = message.guild.voice_client
if voice_client is None:
# don't play anything and clear queue for whole guild