[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.
This commit is contained in:
aikaterna 2019-07-01 20:15:34 -07:00 committed by Toby Harradine
parent 93391d028c
commit d1593b8069

View File

@ -1211,6 +1211,8 @@ class Audio(commands.Cog):
async def _folder_list(self, ctx, folder): async def _folder_list(self, ctx, folder):
if not await self._localtracks_check(ctx): if not await self._localtracks_check(ctx):
return return
if not os.path.isdir(os.getcwd() + "/localtracks/{}/".format(folder)):
return
allowed_files = (".mp3", ".flac", ".ogg") allowed_files = (".mp3", ".flac", ".ogg")
folder_list = sorted( folder_list = sorted(
( (
@ -1237,6 +1239,8 @@ class Audio(commands.Cog):
async def _folder_tracks(self, ctx, player, folder): async def _folder_tracks(self, ctx, player, folder):
if not await self._localtracks_check(ctx): if not await self._localtracks_check(ctx):
return return
if not os.path.isdir(os.getcwd() + "/localtracks/{}/".format(folder)):
return
local_tracks = [] local_tracks = []
for local_file in await self._all_folder_tracks(ctx, folder): for local_file in await self._all_folder_tracks(ctx, folder):
track = await player.get_tracks("localtracks/{}/{}".format(folder, local_file)) track = await player.get_tracks("localtracks/{}/{}".format(folder, local_file))