mirror of
https://github.com/weyne85/discord_music_bot.git
synced 2025-10-29 16:58:27 +00:00
Sending initial changes, adding the concept of Handlers, Views, Exceptions and Result, these class will optimaze the code in terms of cleanliness and organizational
This commit is contained in:
34
vulkan/controllers/AbstractHandler.py
Normal file
34
vulkan/controllers/AbstractHandler.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from discord.ext.commands import Context
|
||||
from discord import Client, Guild
|
||||
from vulkan.controllers.PlayerController import PlayersController
|
||||
from vulkan.music.Player import Player
|
||||
from vulkan.results.AbstractResult import AbstractResult
|
||||
|
||||
|
||||
class AbstractHandler(ABC):
|
||||
def __init__(self, ctx: Context, bot: Client) -> None:
|
||||
self.__bot: Client = bot
|
||||
self.__controller = PlayersController(self.__bot)
|
||||
self.__player: Player = self.__controller.get_player(ctx.guild)
|
||||
self.__guild: Guild = ctx.guild
|
||||
|
||||
@abstractmethod
|
||||
async def run(self) -> AbstractResult:
|
||||
pass
|
||||
|
||||
@property
|
||||
def guild(self) -> Guild:
|
||||
return self.__guild
|
||||
|
||||
@property
|
||||
def player(self) -> Player:
|
||||
return self.__player
|
||||
|
||||
@property
|
||||
def controller(self) -> PlayersController:
|
||||
return self.__controller
|
||||
|
||||
@property
|
||||
def bot(self) -> Client:
|
||||
return self.__bot
|
||||
Reference in New Issue
Block a user