diff --git a/Discord/cogs/audio.py b/Discord/cogs/audio.py index b7d106f171..6e660187d7 100644 --- a/Discord/cogs/audio.py +++ b/Discord/cogs/audio.py @@ -46,8 +46,8 @@ async def cog_check(self, ctx): @commands.hybrid_group( aliases = [ - "soundcloud", "voice", "stream", "play", "playlist", "spotify", - "budio", "music", "download" + "soundcloud", "voice", "stream", "play", "playlist", "budio", + "music", "download" ], description = "Supports [these sites](https://rg3.github.io/youtube-dl/supportedsites.html) and Spotify", case_insensitive = True @@ -59,14 +59,8 @@ async def audio(self, ctx, *, song: Optional[str]): #elif options[0] == "full": All audio subcommands are also commands For cleanup of audio commands, the Manage Messages permission is required ''' + # Note: spotify command invokes this command # Note: youtube command invokes this command - if song and song.lower().startswith("info "): - if ctx.invoked_with.lower() == "spotify": - await ctx.invoke( - self.bot.cogs["Information"].spotify, - song.lstrip(song.split()[0]).lstrip() - ) - return if not ctx.guild.voice_client: if ctx.guild.id not in self.players: self.players[ctx.guild.id] = AudioPlayer.from_context(ctx) @@ -114,6 +108,36 @@ async def audio(self, ctx, *, song: Optional[str]): #elif options[0] == "full": finally: await response.edit(embed = embed) + @commands.group( + case_insensitive = True, invoke_without_command = True, + description = "Supports [these sites](https://rg3.github.io/youtube-dl/supportedsites.html) and Spotify" + ) + @checks.not_forbidden() + async def spotify(self, ctx, *, song: Optional[str]): + ''' + Audio System - play a song + All audio subcommands are also commands + For cleanup of audio commands, the Manage Messages permission is required + ''' + if command := ctx.bot.get_command("audio"): + await ctx.invoke(command, song = song) + else: + raise RuntimeError( + "audio command not found when spotify command invoked" + ) + + @spotify.command(name = "information", aliases = ["info"]) + @checks.not_forbidden() + async def spotify_information(self, ctx, url: str): + '''Information about a Spotify track''' + if command := ctx.bot.get_command("information spotify"): + await ctx.invoke(command, url = url) + else: + raise RuntimeError( + "information spotify command not found " + "when spotify information command invoked" + ) + @commands.hybrid_group( aliases = ["yt"], case_insensitive = True, with_app_command = False, diff --git a/Discord/cogs/information.py b/Discord/cogs/information.py index 84e988d88c..07d823cd6f 100644 --- a/Discord/cogs/information.py +++ b/Discord/cogs/information.py @@ -160,6 +160,7 @@ async def server(self, ctx): @information.command(with_app_command = False) async def spotify(self, ctx, url: str): '''Information about a Spotify track''' + # Note: spotify information command invokes this command path = urllib.parse.urlparse(url).path if path[:7] != "/track/":