fix repeat cmd
This commit is contained in:
parent
d1af880652
commit
fe649d530b
1 changed files with 6 additions and 8 deletions
|
@ -43,8 +43,7 @@ class Mybot(commands.Cog):
|
||||||
else:
|
else:
|
||||||
folder = folder.lower()
|
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()])
|
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((audio_file,ctx))
|
||||||
self.sounds.append((source,ctx))
|
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def repeat(self, ctx):
|
async def repeat(self, ctx):
|
||||||
|
@ -78,12 +77,10 @@ class Mybot(commands.Cog):
|
||||||
print(user)
|
print(user)
|
||||||
try:
|
try:
|
||||||
audio_file = random.choice([f for f in os.listdir('/home/mika/kabot/kabot/kabot/Audio/%s/' % user) if f.endswith('.mp3')])
|
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:
|
except:
|
||||||
audio_file = random.choice([f for f in Path('/home/mika/kabot/kabot/kabot/Audio/').glob('**/*.mp3')])
|
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((audio_file,ctx))
|
||||||
self.sounds.append((source,ctx))
|
|
||||||
print(self.sounds)
|
|
||||||
|
|
||||||
@commands.command(help='Update local repo')
|
@commands.command(help='Update local repo')
|
||||||
async def update(self, message):
|
async def update(self, message):
|
||||||
|
@ -166,12 +163,13 @@ class Mybot(commands.Cog):
|
||||||
@tasks.loop(seconds=1.5)
|
@tasks.loop(seconds=1.5)
|
||||||
async def play_next(self):
|
async def play_next(self):
|
||||||
if self.sounds:
|
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():
|
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)
|
ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None)
|
||||||
self.sounds.pop(0)
|
self.sounds.pop(0)
|
||||||
self.sounds_history.reverse()
|
self.sounds_history.reverse()
|
||||||
self.sounds_history.append((source,ctx))
|
self.sounds_history.append((audio_file,ctx))
|
||||||
self.sounds_history.reverse()
|
self.sounds_history.reverse()
|
||||||
if len(self.sounds_history) >5:
|
if len(self.sounds_history) >5:
|
||||||
self.sounds_history = self.sounds_history[:5]
|
self.sounds_history = self.sounds_history[:5]
|
||||||
|
|
Loading…
Reference in a new issue