Modifying clear and skip commands to work with process

This commit is contained in:
Rafael Vargas
2022-07-22 22:57:27 -03:00
parent 19ae59c5b8
commit 1ce6deaa48
3 changed files with 67 additions and 45 deletions

View File

@@ -2,6 +2,7 @@ from discord.ext.commands import Context
from discord import Client
from Controllers.AbstractController import AbstractController
from Controllers.ControllerResponse import ControllerResponse
from Parallelism.ProcessManager import ProcessManager
class ClearController(AbstractController):
@@ -9,5 +10,13 @@ class ClearController(AbstractController):
super().__init__(ctx, bot)
async def run(self) -> ControllerResponse:
self.player.playlist.clear()
# Get the current process of the guild
processManager = ProcessManager()
processContext = processManager.getRunningPlayerContext(self.guild)
if processContext:
# Clear the playlist
playlist = processContext.getPlaylist()
with processContext.getLock():
playlist.clear()
return ControllerResponse(self.ctx)