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
+7 -7
View File
@@ -217,7 +217,7 @@ class Music(commands.Cog):
async def play(self, ctx: CustomContext):
"""Starts playing Christmas bangers"""
# Get the player for this guild from cache.
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
player = ctx.get_player()
await self.fill_player_queue(player, self.bot.config["queue_buffer_size"])
if not player.is_playing:
@@ -226,22 +226,22 @@ class Music(commands.Cog):
await ctx.send("Started playing")
@commands.command(name="skip", aliases=["next"])
async def skip(self, ctx: Context):
async def skip(self, ctx: CustomContext):
"""I heard this song way too often"""
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
player = ctx.get_player()
await player.skip()
await ctx.send("Skipped current song")
@commands.command(name="queue")
async def queue(self, ctx: Context):
async def queue(self, ctx: CustomContext):
"""Ghetto queue"""
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
player = ctx.get_player()
await EmbedGenerator.Message(ctx, "Queue:", player.queue)
@commands.command(name="disconnect", aliases=["dc", "stop"])
async def disconnect(self, ctx: Context):
async def disconnect(self, ctx: CustomContext):
"""Disconnects ChristmasBot"""
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
player = ctx.get_player()
if not player.is_connected:
return await EmbedGenerator.Title(ctx, "Not connected.")