[Audio] Play local folders via text command (#2457)

`[p]local folder` will now accept folder names in the command instead of having to navigate through the reaction menu. Also added an alias of `[p]local start` to help users coming from v2 audio.
This commit is contained in:
aikaterna 2019-02-18 15:16:41 -08:00 committed by Toby Harradine
parent 83411d0fa4
commit 7e2e37ab3f

View File

@ -554,12 +554,22 @@ class Audio(commands.Cog):
"""Local playback commands.""" """Local playback commands."""
pass pass
@local.command(name="folder") @local.command(name="folder", aliases=["start"])
async def local_folder(self, ctx): async def local_folder(self, ctx, folder=None):
"""Play all songs in a localtracks folder.""" """Play all songs in a localtracks folder."""
if not await self._localtracks_check(ctx): if not await self._localtracks_check(ctx):
return return
await ctx.invoke(self.local_play) if not folder:
await ctx.invoke(self.local_play)
else:
try:
folder_path = os.getcwd() + "/localtracks/{}/".format(folder)
os.listdir(folder_path)
except OSError:
return await self._embed_msg(
ctx, _("No localtracks folder named {name}.").format(name=folder)
)
await self._local_play_all(ctx, folder)
@local.command(name="play") @local.command(name="play")
async def local_play(self, ctx): async def local_play(self, ctx):