mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[V3 Audio] Playlist info improvements (#2274)
* [V3 Audio] Playlist info improvements * Add pagify import, reformat for Black * Change from code block to embed with links
This commit is contained in:
parent
80fc639480
commit
2a486cad66
@ -18,7 +18,7 @@ import redbot.core
|
|||||||
from redbot.core import Config, commands, checks, bank
|
from redbot.core import Config, commands, checks, bank
|
||||||
from redbot.core.data_manager import cog_data_path
|
from redbot.core.data_manager import cog_data_path
|
||||||
from redbot.core.i18n import Translator, cog_i18n
|
from redbot.core.i18n import Translator, cog_i18n
|
||||||
from redbot.core.utils.chat_formatting import bold, box
|
from redbot.core.utils.chat_formatting import bold, box, pagify
|
||||||
from redbot.core.utils.menus import (
|
from redbot.core.utils.menus import (
|
||||||
menu,
|
menu,
|
||||||
DEFAULT_CONTROLS,
|
DEFAULT_CONTROLS,
|
||||||
@ -1605,25 +1605,46 @@ class Audio(commands.Cog):
|
|||||||
author_id = playlists[playlist_name]["author"]
|
author_id = playlists[playlist_name]["author"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return await self._embed_msg(ctx, _("No playlist with that name."))
|
return await self._embed_msg(ctx, _("No playlist with that name."))
|
||||||
author_obj = self.bot.get_user(author_id)
|
|
||||||
playlist_url = playlists[playlist_name]["playlist_url"]
|
|
||||||
try:
|
try:
|
||||||
track_len = len(playlists[playlist_name]["tracks"])
|
track_len = len(playlists[playlist_name]["tracks"])
|
||||||
except TypeError:
|
except TypeError:
|
||||||
track_len = 0
|
track_len = 0
|
||||||
if playlist_url is None:
|
|
||||||
playlist_url = _("**Custom playlist.**")
|
msg = ""
|
||||||
|
track_idx = 0
|
||||||
|
if track_len > 0:
|
||||||
|
for track in playlists[playlist_name]["tracks"]:
|
||||||
|
track_idx = track_idx + 1
|
||||||
|
spaces = abs(len(str(track_idx)) - 5)
|
||||||
|
msg += "`{}.` **[{}]({})**\n".format(
|
||||||
|
track_idx, track["info"]["title"], track["info"]["uri"]
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
playlist_url = _("URL: <{url}>").format(url=playlist_url)
|
msg = "No tracks."
|
||||||
embed = discord.Embed(
|
playlist_url = playlists[playlist_name]["playlist_url"]
|
||||||
colour=await ctx.embed_colour(),
|
if not playlist_url:
|
||||||
title=_("Playlist info for {playlist_name}:").format(playlist_name=playlist_name),
|
embed_title = _("Playlist info for {playlist_name}:\n").format(
|
||||||
description=_("Author: **{author_name}**\n{url}").format(
|
playlist_name=playlist_name
|
||||||
author_name=author_obj, url=playlist_url
|
)
|
||||||
),
|
else:
|
||||||
)
|
embed_title = _("Playlist info for {playlist_name}:\nURL: {url}").format(
|
||||||
embed.set_footer(text=_("{num} track(s)").format(num=track_len))
|
playlist_name=playlist_name, url=playlist_url
|
||||||
await ctx.send(embed=embed)
|
)
|
||||||
|
|
||||||
|
page_list = []
|
||||||
|
for page in pagify(msg, delims=["\n"], page_length=1000):
|
||||||
|
embed = discord.Embed(
|
||||||
|
colour=await ctx.embed_colour(), title=embed_title, description=page
|
||||||
|
)
|
||||||
|
author_obj = self.bot.get_user(author_id)
|
||||||
|
embed.set_footer(
|
||||||
|
text=_("Author: {author_name} | {num} track(s)").format(
|
||||||
|
author_name=author_obj, num=track_len
|
||||||
|
)
|
||||||
|
)
|
||||||
|
page_list.append(embed)
|
||||||
|
await menu(ctx, page_list, DEFAULT_CONTROLS)
|
||||||
|
|
||||||
@playlist.command(name="list")
|
@playlist.command(name="list")
|
||||||
async def _playlist_list(self, ctx):
|
async def _playlist_list(self, ctx):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user