Skip to content

Commit 554221b

Browse files
author
skillor
committed
hotfix: audio on coinflip
1 parent 14e976f commit 554221b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

bot.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,10 +1644,15 @@ async def _coinflip(self, ctx, *args):
16441644
voice_client = None
16451645
if random.random() < await self.parent.get_setting(prev_author.guild.id, 'COIN_FLIP_AUDIO_CHANCE'):
16461646
if prev_author.voice is not None and prev_author.voice.channel is not None:
1647-
voice_channel = prev_author.voice.channel
1648-
voice_client = await voice_channel.connect()
1649-
audio_source = discord.FFmpegPCMAudio(os.path.join('audio', 'tossacoin.mp3'))
1650-
voice_client.play(audio_source)
1647+
try:
1648+
voice_channel = prev_author.voice.channel
1649+
voice_client = await voice_channel.connect()
1650+
audio_source = discord.FFmpegPCMAudio(os.path.join('audio', 'tossacoin.mp3'))
1651+
voice_client.play(audio_source)
1652+
except discord.ClientException:
1653+
self.parent.lprint('Bot is alreardy connect to a voice channel')
1654+
except RuntimeError as e:
1655+
self.parent.lprint(e)
16511656

16521657
await asyncio.sleep(13)
16531658

0 commit comments

Comments
 (0)