mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[V3 Audio] Fix for playlist queue duplicates (#1890)
* [V3 Audio] Fix for playlist queue duplicates And some sanitizing of playlist names. * [V3 Audio] Playlist naming standardization Enforced single-word playlist name across all playlist commands, removed A-Z 0-9 name standardization. [p]playlist delete will still accept playlist names with quotes as there should be a way to remove already-existing playlists with spaces in their name. * [V3 Audio] Black formatting
This commit is contained in:
parent
43c7bd48c7
commit
2df282222f
@ -714,6 +714,7 @@ class Audio:
|
|||||||
return await self._embed_msg(
|
return await self._embed_msg(
|
||||||
ctx, "Playlist name already exists, try again with a different name."
|
ctx, "Playlist name already exists, try again with a different name."
|
||||||
)
|
)
|
||||||
|
playlist_name = playlist_name.split(" ")[0].strip('"')
|
||||||
playlist_list = self._to_json(ctx, None, None)
|
playlist_list = self._to_json(ctx, None, None)
|
||||||
async with self.config.guild(ctx.guild).playlists() as playlists:
|
async with self.config.guild(ctx.guild).playlists() as playlists:
|
||||||
playlists[playlist_name] = playlist_list
|
playlists[playlist_name] = playlist_list
|
||||||
@ -775,6 +776,7 @@ class Audio:
|
|||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
|
@commands.cooldown(1, 15, discord.ext.commands.BucketType.guild)
|
||||||
@playlist.command(name="queue")
|
@playlist.command(name="queue")
|
||||||
async def _playlist_queue(self, ctx, playlist_name=None):
|
async def _playlist_queue(self, ctx, playlist_name=None):
|
||||||
"""Save the queue to a playlist."""
|
"""Save the queue to a playlist."""
|
||||||
@ -801,11 +803,11 @@ class Audio:
|
|||||||
await self._embed_msg(ctx, "Please enter a name for this playlist.")
|
await self._embed_msg(ctx, "Please enter a name for this playlist.")
|
||||||
|
|
||||||
def check(m):
|
def check(m):
|
||||||
return m.author == ctx.author
|
return m.author == ctx.author and not m.content.startswith(ctx.prefix)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
playlist_name_msg = await ctx.bot.wait_for("message", timeout=15.0, check=check)
|
playlist_name_msg = await ctx.bot.wait_for("message", timeout=15.0, check=check)
|
||||||
playlist_name = str(playlist_name_msg.content)
|
playlist_name = playlist_name_msg.content.split(" ")[0].strip('"')
|
||||||
if len(playlist_name) > 20:
|
if len(playlist_name) > 20:
|
||||||
return await self._embed_msg(ctx, "Try the command again with a shorter name.")
|
return await self._embed_msg(ctx, "Try the command again with a shorter name.")
|
||||||
if playlist_name in playlists:
|
if playlist_name in playlists:
|
||||||
@ -816,11 +818,12 @@ class Audio:
|
|||||||
return await self._embed_msg(ctx, "No playlist name entered, try again later.")
|
return await self._embed_msg(ctx, "No playlist name entered, try again later.")
|
||||||
playlist_list = self._to_json(ctx, None, tracklist)
|
playlist_list = self._to_json(ctx, None, tracklist)
|
||||||
async with self.config.guild(ctx.guild).playlists() as playlists:
|
async with self.config.guild(ctx.guild).playlists() as playlists:
|
||||||
|
playlist_name = playlist_name.split(" ")[0].strip('"')
|
||||||
playlists[playlist_name] = playlist_list
|
playlists[playlist_name] = playlist_list
|
||||||
await self._embed_msg(
|
await self._embed_msg(
|
||||||
ctx,
|
ctx,
|
||||||
"Playlist {} saved from current queue: {} tracks added.".format(
|
"Playlist {} saved from current queue: {} tracks added.".format(
|
||||||
playlist_name, len(tracklist)
|
playlist_name.split(" ")[0].strip('"'), len(tracklist)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -868,6 +871,7 @@ class Audio:
|
|||||||
playlist_list = self._to_json(ctx, playlist_url, tracklist)
|
playlist_list = self._to_json(ctx, playlist_url, tracklist)
|
||||||
if tracklist is not None:
|
if tracklist is not None:
|
||||||
async with self.config.guild(ctx.guild).playlists() as playlists:
|
async with self.config.guild(ctx.guild).playlists() as playlists:
|
||||||
|
playlist_name = playlist_name.split(" ")[0].strip('"')
|
||||||
playlists[playlist_name] = playlist_list
|
playlists[playlist_name] = playlist_list
|
||||||
return await self._embed_msg(
|
return await self._embed_msg(
|
||||||
ctx,
|
ctx,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user