Skip to content

Commit

Permalink
hotfix: audio on coinflip
Browse files Browse the repository at this point in the history
  • Loading branch information
skillor committed May 24, 2021
1 parent 14e976f commit 554221b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1644,10 +1644,15 @@ async def _coinflip(self, ctx, *args):
voice_client = None
if random.random() < await self.parent.get_setting(prev_author.guild.id, 'COIN_FLIP_AUDIO_CHANCE'):
if prev_author.voice is not None and prev_author.voice.channel is not None:
voice_channel = prev_author.voice.channel
voice_client = await voice_channel.connect()
audio_source = discord.FFmpegPCMAudio(os.path.join('audio', 'tossacoin.mp3'))
voice_client.play(audio_source)
try:
voice_channel = prev_author.voice.channel
voice_client = await voice_channel.connect()
audio_source = discord.FFmpegPCMAudio(os.path.join('audio', 'tossacoin.mp3'))
voice_client.play(audio_source)
except discord.ClientException:
self.parent.lprint('Bot is alreardy connect to a voice channel')
except RuntimeError as e:
self.parent.lprint(e)

await asyncio.sleep(13)

Expand Down

0 comments on commit 554221b

Please sign in to comment.