[Audio] Add playlist create command (#339)

This commit is contained in:
Caleb Johnson 2016-08-10 16:02:29 -05:00 committed by Twentysix
parent ebab92f61d
commit bab4eb10f8

View File

@ -1290,6 +1290,29 @@ class Audio:
if ctx.invoked_subcommand is None:
await send_cmd_help(ctx)
@playlist.command(pass_context=True, no_pm=True, name="create")
async def playlist_create(self, ctx, name):
"""Creates an empty playlist"""
server = ctx.message.server
author = ctx.message.author
if not self._valid_playlist_name(name) or len(name) > 25:
await self.bot.say("That playlist name is invalid. It must only"
" contain alpha-numeric characters or _.")
return
# Returns a Playlist object
url = None
songlist = []
playlist = self._make_playlist(author, url, songlist)
playlist.name = name
playlist.server = server
self._save_playlist(server, name, playlist)
await self.bot.say("Empty playlist '{}' saved.".format(name))
@playlist.command(pass_context=True, no_pm=True, name="add")
async def playlist_add(self, ctx, name, url):
"""Add a YouTube or Soundcloud playlist."""