mirror of
https://github.com/jarulsamy/Plex-Bot.git
synced 2024-08-19 15:01:55 +02:00
implemented looping of tracks
This commit is contained in:
parent
15b7e0f50e
commit
069d88fd1e
@ -203,6 +203,7 @@ class Plex(commands.Cog):
|
|||||||
# Initialize necessary vars
|
# Initialize necessary vars
|
||||||
self.voice_channel = None
|
self.voice_channel = None
|
||||||
self.current_track = None
|
self.current_track = None
|
||||||
|
self.is_looping = False
|
||||||
self.np_message_id = None
|
self.np_message_id = None
|
||||||
self.show_queue_message_ids = []
|
self.show_queue_message_ids = []
|
||||||
self.ctx = None
|
self.ctx = None
|
||||||
@ -312,10 +313,13 @@ class Plex(commands.Cog):
|
|||||||
self.np_message_id = await self.ctx.send(embed=embed, file=img)
|
self.np_message_id = await self.ctx.send(embed=embed, file=img)
|
||||||
|
|
||||||
async def _play_next(self):
|
async def _play_next(self):
|
||||||
try:
|
if self.is_looping:
|
||||||
self.current_track = await self.play_queue.get()
|
self.current_track = self.is_looping
|
||||||
except asyncio.exceptions.CancelledError:
|
else:
|
||||||
bot_log.debug("failed to pop queue")
|
try:
|
||||||
|
self.current_track = await self.play_queue.get()
|
||||||
|
except asyncio.exceptions.CancelledError:
|
||||||
|
bot_log.debug("failed to pop queue")
|
||||||
|
|
||||||
|
|
||||||
async def _audio_player_task(self):
|
async def _audio_player_task(self):
|
||||||
@ -716,6 +720,41 @@ class Plex(commands.Cog):
|
|||||||
bot_log.debug("Stopped")
|
bot_log.debug("Stopped")
|
||||||
await ctx.send(":stop_button: 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()
|
@command()
|
||||||
async def pause(self, ctx):
|
async def pause(self, ctx):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user