Vulkan/Handlers/ClearHandler.py

23 lines
786 B
Python

from discord.ext.commands import Context
from discord import Client
from Handlers.AbstractHandler import AbstractHandler
from Handlers.HandlerResponse import HandlerResponse
from Parallelism.ProcessManager import ProcessManager
class ClearHandler(AbstractHandler):
def __init__(self, ctx: Context, bot: Client) -> None:
super().__init__(ctx, bot)
async def run(self) -> HandlerResponse:
# Get the current process of the guild
processManager = ProcessManager()
processInfo = processManager.getRunningPlayerInfo(self.guild)
if processInfo:
# Clear the playlist
playlist = processInfo.getPlaylist()
with processInfo.getLock():
playlist.clear()
return HandlerResponse(self.ctx)