From fe649d530b3612c94a0dcd1ed09fbab60c1cfd01 Mon Sep 17 00:00:00 2001 From: Milka64 Date: Sat, 21 Mar 2020 14:57:15 +0100 Subject: [PATCH] fix repeat cmd --- kabot/kabot/kabot.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/kabot/kabot/kabot.py b/kabot/kabot/kabot.py index 2fea667..a155942 100644 --- a/kabot/kabot/kabot.py +++ b/kabot/kabot/kabot.py @@ -43,8 +43,7 @@ class Mybot(commands.Cog): else: folder = folder.lower() audio_file = random.choice([f for f in Path('/home/mika/kabot/kabot/kabot/Audio/').glob('**/*.mp3') if folder in str(f).lower()]) - source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(audio_file)) - self.sounds.append((source,ctx)) + self.sounds.append((audio_file,ctx)) @commands.command() async def repeat(self, ctx): @@ -78,12 +77,10 @@ class Mybot(commands.Cog): print(user) try: audio_file = random.choice([f for f in os.listdir('/home/mika/kabot/kabot/kabot/Audio/%s/' % user) if f.endswith('.mp3')]) - source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio("/home/mika/kabot/kabot/kabot/Audio/%s/%s" % (user,audio_file))) + audio_file = '/home/mika/kabot/kabot/kabot/Audio/%s/' % user + audio_file except: audio_file = random.choice([f for f in Path('/home/mika/kabot/kabot/kabot/Audio/').glob('**/*.mp3')]) - source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(audio_file)) - self.sounds.append((source,ctx)) - print(self.sounds) + self.sounds.append((audio_file,ctx)) @commands.command(help='Update local repo') async def update(self, message): @@ -166,12 +163,13 @@ class Mybot(commands.Cog): @tasks.loop(seconds=1.5) async def play_next(self): if self.sounds: - source,ctx = self.sounds[0] + audio_file,ctx = self.sounds[0] + source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(audio_file)) if not ctx.voice_client.is_playing() and ctx.voice_client.is_connected(): ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None) self.sounds.pop(0) self.sounds_history.reverse() - self.sounds_history.append((source,ctx)) + self.sounds_history.append((audio_file,ctx)) self.sounds_history.reverse() if len(self.sounds_history) >5: self.sounds_history = self.sounds_history[:5]