decoupled lavalink creation from cogs.music

This commit is contained in:
2021-11-20 00:37:17 +01:00
parent 1697002666
commit 8504d6abfd
5 changed files with 24 additions and 21 deletions
+5 -1
View File
@@ -8,16 +8,20 @@ from lavalink.models import DefaultPlayer
if TYPE_CHECKING:
from bot import TuneBot
from utils.classes import BaseCog
class CustomContext(commands.Context):
bot: "TuneBot"
cog: "BaseCog"
@property
def redis(self) -> Redis:
return self.bot._redis_client
@property
def player(self) -> DefaultPlayer:
if hasattr(self.bot, "lavalink"):
if self.cog.is_lavalink_ready():
return self.bot.lavalink.player_manager.get(self.guild.id)
raise CommandInvokeError("Lavalink is still starting up.")