fix os.path error

This commit is contained in:
Milka64 2020-05-05 21:16:42 +02:00
parent ae285863d1
commit 477e765316

View file

@ -199,10 +199,10 @@ class Mybot(commands.Cog):
async def joke(self, ctx, folder=None): async def joke(self, ctx, folder=None):
user = ctx.message.author.name user = ctx.message.author.name
if not folder or not ctx.message.content: if not folder or not ctx.message.content:
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3')]) audio_file = random.choice([f"{f}" for f in Path(here + '/Audio/').glob('**/*.mp3')])
else: else:
folder = folder.lower() folder = folder.lower()
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3') if folder in str(f).lower()]) audio_file = random.choice([f"{f}" for f in Path(here + '/Audio/').glob('**/*.mp3') if folder in str(f).lower()])
self.sounds.append((audio_file, ctx)) self.sounds.append((audio_file, ctx))
@commands.command(help="optionnal args : [livre] [character]") @commands.command(help="optionnal args : [livre] [character]")
@ -386,7 +386,7 @@ class Mybot(commands.Cog):
audio_file = random.choice([f for f in os.listdir(here + '/Audio/%s/' % user) if f.endswith('.mp3')]) audio_file = random.choice([f for f in os.listdir(here + '/Audio/%s/' % user) if f.endswith('.mp3')])
audio_file = here + '/Audio/%s/' % user + audio_file audio_file = here + '/Audio/%s/' % user + audio_file
except: except:
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3')]) audio_file = random.choice([f"{f}" for f in Path(here + '/Audio/').glob('**/*.mp3')])
self.sounds.append((audio_file, ctx)) self.sounds.append((audio_file, ctx))
#Fin des commandes pour faire mumuse avec Kabot. #Fin des commandes pour faire mumuse avec Kabot.