Skip to content

Commit 14e976f

Browse files
author
skillor
committed
hotfix: coinflip audio on slash command
1 parent 846f002 commit 14e976f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

bot.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,18 +1636,18 @@ async def _coinflip(self, ctx, *args):
16361636
res = 'kopf'
16371637
else:
16381638
res = 'zahl'
1639+
1640+
prev_author = ctx.message.author
1641+
16391642
message = await ctx.send(file=discord.File(os.path.join('images', '{}.gif'.format(res))))
16401643

16411644
voice_client = None
1642-
if random.random() < await self.parent.get_setting(ctx.message.author.guild.id, 'COIN_FLIP_AUDIO_CHANCE'):
1643-
if ctx.message.author.voice is not None and ctx.message.author.voice.channel is not None:
1644-
try:
1645-
voice_channel = ctx.message.author.voice.channel
1646-
voice_client = await voice_channel.connect()
1647-
audio_source = discord.FFmpegPCMAudio(os.path.join('audio', 'tossacoin.mp3'))
1648-
voice_client.play(audio_source)
1649-
except discord.ClientException:
1650-
pass
1645+
if random.random() < await self.parent.get_setting(prev_author.guild.id, 'COIN_FLIP_AUDIO_CHANCE'):
1646+
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)
16511651

16521652
await asyncio.sleep(13)
16531653

0 commit comments

Comments
 (0)