From 5207baf83fd3c07f16b873956dea07790657c8a4 Mon Sep 17 00:00:00 2001 From: Milka64 Date: Thu, 18 Feb 2021 22:08:17 +0100 Subject: [PATCH] WIP on #11 --- kabot/kabot/kabot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kabot/kabot/kabot.py b/kabot/kabot/kabot.py index bddfbdb..1906fda 100644 --- a/kabot/kabot/kabot.py +++ b/kabot/kabot/kabot.py @@ -247,10 +247,12 @@ class Mybot(commands.Cog): audio_file = random.choice([f"{f}" for f in Path(self.audio_path + '/').glob('**/*.mp3')]) else: folder = folder.lower() - audio_file = random.choice([f"{f}" for f in Path(self.audio_path + '/').glob('**/*.mp3') if folder in str(f).lower()]) + audio_file = [f"{f}" for f in Path(self.audio_path + '/').glob('**/*.mp3') if folder in str(f).lower()] if not audio_file: ctx.channel.send("%s not found" % folder) - self.sounds.append((audio_file, ctx)) + else: + audio_file = random.choice(audio_file) + self.sounds.append((audio_file, ctx)) except: e = exc_info()[0] await ctx.channel.send("Exception when calling joke: %s\n" % e)