Added context shortcut to get the lavalink player

This commit is contained in:
2021-11-06 10:45:23 +01:00
parent f8e72443f4
commit 10e05ad350
3 changed files with 18 additions and 9 deletions
+8
View File
@@ -1,7 +1,15 @@
from aioredis.client import Redis
from discord.ext import commands
from discord.ext.commands.errors import CommandInvokeError
from lavalink.models import DefaultPlayer
class CustomContext(commands.Context):
def get_redis(self) -> Redis:
return self.bot._redis_client
def get_player(self) -> DefaultPlayer:
if hasattr(self.bot, "lavalink"):
return self.bot.lavalink.player_manager.get(self.guild.id)
raise CommandInvokeError("Lavalink is still starting up.")