add repeat cmd

This commit is contained in:
Milka64 2020-03-15 21:12:40 +01:00
parent 2598511bf5
commit 089818e48c

View file

@ -19,6 +19,7 @@ class Mybot(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
self.sounds = [] self.sounds = []
self.sounds_history = []
self.play_next.start() self.play_next.start()
@commands.command() @commands.command()
@ -43,6 +44,13 @@ class Mybot(commands.Cog):
source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(audio_file)) source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(audio_file))
self.sounds.append((source,ctx)) 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() @commands.command()
async def welcome(self, ctx): async def welcome(self, ctx):
#if ctx.message.author.name == self.bot.user.name: #if ctx.message.author.name == self.bot.user.name:
@ -139,6 +147,9 @@ class Mybot(commands.Cog):
async def play_next(self): async def play_next(self):
if self.sounds: if self.sounds:
source,ctx = self.sounds[0] 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(): 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)