aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/vclogs.py
diff options
context:
space:
mode:
Diffstat (limited to 'cogs/vclogs.py')
-rw-r--r--cogs/vclogs.py15
1 files changed, 2 insertions, 13 deletions
diff --git a/cogs/vclogs.py b/cogs/vclogs.py
index 64c356d..a9672ac 100644
--- a/cogs/vclogs.py
+++ b/cogs/vclogs.py
@@ -50,22 +50,11 @@ class VcLogs(commands.Cog):
50 tts = gTTS(text=text, lang='pl') 50 tts = gTTS(text=text, lang='pl')
51 tts.save('temp_tts.mp3') 51 tts.save('temp_tts.mp3')
52 52
53 # Get the voice client for the guild 53 # Connect to the voice channel if not already connected
54 voice_client = discord.utils.get(self.bot.voice_clients, guild=channel.guild) 54 voice_client = discord.utils.get(self.bot.voice_clients, guild=channel.guild)
55
56 # Handle connection state
57 if not voice_client or not voice_client.is_connected(): 55 if not voice_client or not voice_client.is_connected():
58 # If no voice client or not connected, create a new connection 56 voice_client = await channel.connect()
59 try:
60 voice_client = await channel.connect()
61 except discord.ClientException as e:
62 if 'already connected' in str(e).lower():
63 # If already connected, find the existing connection
64 voice_client = next((vc for vc in self.bot.voice_clients if vc.guild == channel.guild), None)
65 else:
66 raise
67 elif voice_client.channel != channel: 57 elif voice_client.channel != channel:
68 # If connected to a different channel, move to the new one
69 await voice_client.move_to(channel) 58 await voice_client.move_to(channel)
70 59
71 # Play the TTS audio 60 # Play the TTS audio