From 089818e48cb7ddc73af9155994193d9942455cd2 Mon Sep 17 00:00:00 2001 From: Milka64 Date: Sun, 15 Mar 2020 21:12:40 +0100 Subject: [PATCH] add repeat cmd --- kabot/kabot/kabot.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kabot/kabot/kabot.py b/kabot/kabot/kabot.py index 1f35847..cc1b478 100644 --- a/kabot/kabot/kabot.py +++ b/kabot/kabot/kabot.py @@ -19,6 +19,7 @@ class Mybot(commands.Cog): def __init__(self, bot): self.bot = bot self.sounds = [] + self.sounds_history = [] self.play_next.start() @commands.command() @@ -43,6 +44,13 @@ class Mybot(commands.Cog): source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(audio_file)) self.sounds.append((source,ctx)) + @commands.command() + async def repeat(self, ctx, *args): + #if ctx.message.author.name == self.bot.user.name: + # return + user = ctx.message.author.name + self.sounds.append((source,ctx)) + @commands.command() async def welcome(self, ctx): #if ctx.message.author.name == self.bot.user.name: @@ -139,6 +147,9 @@ class Mybot(commands.Cog): async def play_next(self): if self.sounds: source,ctx = self.sounds[0] + self.sounds_history.insert(source,0) + if self.sounds_history >5: + self.sounds_history = self.sounds_history[:5] 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)