diff --git a/Discord/cogs/audio.py b/Discord/cogs/audio.py index 9de11fcd9a..e74c5e2bd7 100644 --- a/Discord/cogs/audio.py +++ b/Discord/cogs/audio.py @@ -356,6 +356,19 @@ async def radio_off(self, ctx): else: await ctx.embed_reply(":no_entry: Radio is already off") + @audio.command(name = "search") + @checks.not_forbidden() + async def audio_search(self, ctx, *, search): + '''Find a Youtube video''' + # TODO: Only invoke when parent command invoked with youtube or yt + if command := ctx.bot.get_command("search youtube"): + await ctx.invoke(command, search = search) + else: + raise RuntimeError( + "search youtube command not found " + "when audio search command invoked" + ) + @commands.command(aliases = ["set_text"]) @checks.is_voice_connected() @commands.check_any(checks.is_permitted(), checks.is_guild_owner()) diff --git a/Discord/cogs/search.py b/Discord/cogs/search.py index 26ba8c03b6..49a9908019 100644 --- a/Discord/cogs/search.py +++ b/Discord/cogs/search.py @@ -34,14 +34,6 @@ def __init__(self, bot): if isinstance(command, commands.Command) and command.parent is None and name != "search": self.bot.add_command(command) self.search.add_command(command) - # Add search youtube / youtube (audio) search subcommands - command = commands.Command(self.youtube, aliases = ["yt"], checks = [checks.not_forbidden().predicate]) - command.error(self.youtube_error) - self.search.add_command(command) - if (cog := self.bot.get_cog("Audio")) and (parent := getattr(cog, "audio")): - command = commands.Command(self.youtube, name = "search", checks = [checks.not_forbidden().predicate]) - command.error(self.youtube_error) - parent.add_command(command) def cog_unload(self): if (cog := self.bot.get_cog("Audio")) and (parent := getattr(cog, "audio")): @@ -58,8 +50,10 @@ async def search(self, ctx): ''' await ctx.embed_reply(":grey_question: Search what?") + @search.command(aliases = ["yt"]) async def youtube(self, ctx, *, search: str): '''Find a Youtube video''' + # Note: audio search command invokes this command ydl = youtube_dl.YoutubeDL( {"default_search": "auto", "noplaylist": True, "quiet": True} )