add repeat cmd
This commit is contained in:
parent
2598511bf5
commit
089818e48c
1 changed files with 11 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue