implemented looping of tracks

This commit is contained in:
Carsten Burgard 2022-04-15 12:43:55 +02:00
parent 15b7e0f50e
commit 069d88fd1e

View File

@ -203,6 +203,7 @@ class Plex(commands.Cog):
# Initialize necessary vars
self.voice_channel = None
self.current_track = None
self.is_looping = False
self.np_message_id = None
self.show_queue_message_ids = []
self.ctx = None
@ -312,6 +313,9 @@ class Plex(commands.Cog):
self.np_message_id = await self.ctx.send(embed=embed, file=img)
async def _play_next(self):
if self.is_looping:
self.current_track = self.is_looping
else:
try:
self.current_track = await self.play_queue.get()
except asyncio.exceptions.CancelledError:
@ -716,6 +720,41 @@ class Plex(commands.Cog):
bot_log.debug("Stopped")
await ctx.send(":stop_button: Stopped")
@command()
async def loop(self, ctx):
"""
User command to activate looping the current track
Args:
ctx: discord.ext.commands.Context message context from command
Returns:
None
Raises:
None
"""
bot_log.debug("Looping "+str(self.current_track))
self.is_looping = self.current_track
@command()
async def unloop(self, ctx):
"""
User command to deactivate looping the current track
Args:
ctx: discord.ext.commands.Context message context from command
Returns:
None
Raises:
None
"""
bot_log.debug("Unlooping")
self.is_looping = False
@command()
async def pause(self, ctx):
"""