From de31c6b273ca80a36a061f320cb776d6e1fd70d4 Mon Sep 17 00:00:00 2001 From: strNophix Date: Sat, 12 Nov 2022 19:59:59 +0100 Subject: [PATCH] Removed cog commands from music cog --- cogs/music/__init__.py | 85 ++---------------------------------------- 1 file changed, 3 insertions(+), 82 deletions(-) diff --git a/cogs/music/__init__.py b/cogs/music/__init__.py index b74e439..65a62f5 100644 --- a/cogs/music/__init__.py +++ b/cogs/music/__init__.py @@ -1,24 +1,19 @@ -import typing -from cogs.music.commands import MusicCommands import asyncio +import typing from typing import Optional import lavalink -from discord import Embed from discord.channel import TextChannel from discord.ext import commands from discord.ext.commands.errors import CommandError -from lavalink.models import AudioTrack from lavalink.models import DefaultPlayer -from cogs.music import helper from bot import TuneBot +from cogs.music import helper +from cogs.music.commands import MusicCommands from cogs.music.voice_client import LavalinkVoiceClient -from utils.embed import create_embed -from utils.log import logger from context import CustomContext from utils.classes import BaseCog -from utils.EmbedGenerator import EmbedGenerator from utils.exceptions import EmbeddedCommandException @@ -116,80 +111,6 @@ class MusicCog(BaseCog): elif isinstance(event, lavalink.events.TrackEndEvent): await self.fill_player_queue(event.player, 1) - @commands.command(name="connect", aliases=["p", "play", "join"]) - async def play(self, ctx: CustomContext): - """Start the radio""" - logger.info(f"Joining channel {ctx.channel}") - # Get the player for this guild from cache. - if ctx.player.is_connected: - await ctx.send("Already connected") - return - - await self.fill_player_queue( - ctx.player, self.bot.config["queue_buffer_size"] + 1 - ) - - if not ctx.player.is_playing: - await ctx.player.play() - - await EmbedGenerator.Title(ctx, "*⃣ | Connected.") - return - - @commands.command(name="skip", aliases=["next"]) - async def skip(self, ctx: CustomContext): - """Skip the current song""" - await ctx.player.skip() - await ctx.send("Skipped current song") - - @commands.command(name="queue") - async def queue(self, ctx: CustomContext): - """Display the current radio queue""" - embed_color = self.bot.colors["embed"] - embed = Embed(title="Coming Up...", colour=embed_color) - - if len(ctx.player.queue) > 0: - embed.description = "\n".join( - f"{index}. [{track.title}]({track.uri})" - for index, track in enumerate(ctx.player.queue, 1) - ) - else: - embed.description = "We are still determining a playlist" - - await ctx.send(embed=embed) - - @commands.command(name="disconnect", aliases=["dc", "stop"]) - async def disconnect(self, ctx: CustomContext): - """Disconnects the radio from the channel""" - if not ctx.author.voice or ( - ctx.player.is_connected - and ctx.author.voice.channel.id != int(ctx.player.channel_id) - ): - # Abuse prevention. Users not in voice channels, or not in the same voice channel as the bot - # may not disconnect the bot. - await EmbedGenerator.Title(ctx, "You're not in my voicechannel!") - return - - # Clear the queue to ensure old tracks don't start playing - # when someone else queues something. - ctx.player.queue.clear() - # Stop the current track so Lavalink consumes less resources. - await ctx.player.stop() - # Disconnect from the voice channel. - await ctx.voice_client.disconnect(force=True) - await EmbedGenerator.Title(ctx, "*⃣ | Disconnected.") - - @commands.command(name="now") - async def now_playing(self, ctx: CustomContext): - """Displays information about the currently played track""" - if not ctx.player.current: - embed = create_embed(ctx.author) - embed.title = "You're not listening to anything right now." - await ctx.send(embed=embed) - return - - embed = helper.create_track_embed(ctx.player.current) - await ctx.send(embed=embed) - async def setup(bot: "TuneBot"): await bot.add_cog(MusicCog(bot))