From d1593b8069ba582be2af1bc7d73e29dafe8d7e9b Mon Sep 17 00:00:00 2001 From: aikaterna <20862007+aikaterna@users.noreply.github.com> Date: Mon, 1 Jul 2019 20:15:34 -0700 Subject: [PATCH] [Audio] Catch unhandled internal folder types (#2824) The `folder:` and `localfolder:` prefixes are used internally with some localtracks strings to define what to do with the item when it's cycled through the search function. Users theoretically should have never seen this issue as [p]search is used on the user side for YouTube and Soundcloud searching and not local searching, but this handles the issue where a folder is being passed to these functions that doesn't exist. --- redbot/cogs/audio/audio.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/redbot/cogs/audio/audio.py b/redbot/cogs/audio/audio.py index 29a17e678..df63891a0 100644 --- a/redbot/cogs/audio/audio.py +++ b/redbot/cogs/audio/audio.py @@ -1211,6 +1211,8 @@ class Audio(commands.Cog): async def _folder_list(self, ctx, folder): if not await self._localtracks_check(ctx): return + if not os.path.isdir(os.getcwd() + "/localtracks/{}/".format(folder)): + return allowed_files = (".mp3", ".flac", ".ogg") folder_list = sorted( ( @@ -1237,6 +1239,8 @@ class Audio(commands.Cog): async def _folder_tracks(self, ctx, player, folder): if not await self._localtracks_check(ctx): return + if not os.path.isdir(os.getcwd() + "/localtracks/{}/".format(folder)): + return local_tracks = [] for local_file in await self._all_folder_tracks(ctx, folder): track = await player.get_tracks("localtracks/{}/{}".format(folder, local_file))