Adapting History, Loop, Now Playing, Remove, Shuffle and Reset commands to work with process

This commit is contained in:
Rafael Vargas
2022-07-23 13:57:47 -03:00
parent 3eab6176c3
commit 7efed8ab89
13 changed files with 141 additions and 69 deletions

View File

@@ -3,6 +3,7 @@ from discord import Client
from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse
from Utils.Utils import Utils
from Parallelism.ProcessManager import ProcessManager
class HistoryHandler(AbstractHandler):
@@ -10,11 +11,18 @@ class HistoryHandler(AbstractHandler):
super().__init__(ctx, bot)
async def run(self) -> HandlerResponse:
history = self.player.playlist.getSongsHistory()
# Get the current process of the guild
processManager = ProcessManager()
processContext = processManager.getRunningPlayerContext(self.guild)
if processContext:
with processContext.getLock():
playlist = processContext.getPlaylist()
history = playlist.getSongsHistory()
else:
history = []
if len(history) == 0:
text = self.messages.HISTORY_EMPTY
else:
text = f'\n📜 History Length: {len(history)} | Max: {self.config.MAX_SONGS_HISTORY}\n'
for pos, song in enumerate(history, start=1):