Skip to content

Commit

Permalink
Fix TTS erroring?
Browse files Browse the repository at this point in the history
  • Loading branch information
CDE90 committed Mar 4, 2023
1 parent ae1c410 commit 40daa84
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions cogs/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,30 @@ async def play(

vc: Optional[discord.VoiceClient] = None

try:
vc = await interaction.user.voice.channel.connect()
except discord.ClientException:
for c in self.client.voice_clients:
if not isinstance(c, discord.VoiceClient):
continue
if (
c.channel == interaction.user.voice.channel
and c.is_playing()
):
return await interaction.response.send_message(
"Please wait for the current TTS message to finish"
)
elif c.channel == interaction.user.voice.channel:
vc = c
break

if not isinstance(vc, discord.VoiceClient):
for x in self.client.voice_clients:
if not isinstance(x, discord.VoiceClient):
continue
if x.guild.id == interaction.guild.id:
vc = x
break

if vc and vc.is_playing():
return await interaction.response.send_message(
"Unknown error occured. Pleast try again."
"Please wait for the current TTS message to finish."
)

if not isinstance(vc, discord.VoiceClient):
try:
vc = await interaction.user.voice.channel.connect()
except discord.ClientException:
return await interaction.response.send_message(
"Cannot connect to a voice channel I'm already in."
)
except discord.HTTPException:
return await interaction.response.send_message(
"Failed to connect to the voice channel."
)

embed = discord.Embed(
color=discord.Color.green(),
title="**Reading Message**",
Expand Down

0 comments on commit 40daa84

Please sign in to comment.