diff options
| author | salmonik <raisersoft@proton.me> | 2025-10-01 17:18:12 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2025-10-01 17:18:12 +0200 |
| commit | 1af7ddfd8e60fe4860b15c375884f6e38e782bea (patch) | |
| tree | 9f13b58f7e97530d38efbe9089d1197a1ffc3530 /cogs/vclogs.py | |
| parent | delete embed after choosing (diff) | |
| download | senator-sperma-1af7ddfd8e60fe4860b15c375884f6e38e782bea.tar.gz senator-sperma-1af7ddfd8e60fe4860b15c375884f6e38e782bea.zip | |
try except statement for vclogs
Diffstat (limited to 'cogs/vclogs.py')
| -rw-r--r-- | cogs/vclogs.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/cogs/vclogs.py b/cogs/vclogs.py index 7bf179c..01297a6 100644 --- a/cogs/vclogs.py +++ b/cogs/vclogs.py | |||
| @@ -70,14 +70,10 @@ class VcLogs(commands.Cog): | |||
| 70 | 70 | ||
| 71 | # Connect to the voice channel if not already connected | 71 | # Connect to the voice channel if not already connected |
| 72 | voice_client = discord.utils.get(self.bot.voice_clients, guild=channel.guild) | 72 | voice_client = discord.utils.get(self.bot.voice_clients, guild=channel.guild) |
| 73 | try: | 73 | if not isinstance(voice_client, discord.VoiceClient): |
| 74 | if not isinstance(voice_client, discord.VoiceClient): | 74 | voice_client = await channel.connect() |
| 75 | voice_client = await channel.connect() | 75 | elif voice_client.channel != channel: |
| 76 | elif voice_client.channel != channel: | 76 | await voice_client.move_to(channel) |
| 77 | await voice_client.move_to(channel) | ||
| 78 | except discord.errors.ClientException as e: | ||
| 79 | if str(e) == "Not connected to voice.": | ||
| 80 | voice_client = await channel.connect() | ||
| 81 | 77 | ||
| 82 | # Play the TTS audio | 78 | # Play the TTS audio |
| 83 | if not voice_client.is_playing(): | 79 | if not voice_client.is_playing(): |
| @@ -147,4 +143,4 @@ class VcLogs(commands.Cog): | |||
| 147 | 143 | ||
| 148 | 144 | ||
| 149 | def setup(bot): | 145 | def setup(bot): |
| 150 | bot.add_cog(VcLogs(bot)) | 146 | bot.add_cog(VcLogs(bot)) \ No newline at end of file |
