mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -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.data_manager import cog_data_path
|
||||
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 (
|
||||
menu,
|
||||
DEFAULT_CONTROLS,
|
||||
@ -1605,25 +1605,46 @@ class Audio(commands.Cog):
|
||||
author_id = playlists[playlist_name]["author"]
|
||||
except KeyError:
|
||||
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:
|
||||
track_len = len(playlists[playlist_name]["tracks"])
|
||||
except TypeError:
|
||||
track_len = 0
|
||||
if playlist_url is None:
|
||||
playlist_url = _("**Custom playlist.**")
|
||||
else:
|
||||
playlist_url = _("URL: <{url}>").format(url=playlist_url)
|
||||
embed = discord.Embed(
|
||||
colour=await ctx.embed_colour(),
|
||||
title=_("Playlist info for {playlist_name}:").format(playlist_name=playlist_name),
|
||||
description=_("Author: **{author_name}**\n{url}").format(
|
||||
author_name=author_obj, url=playlist_url
|
||||
),
|
||||
|
||||
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"]
|
||||
)
|
||||
embed.set_footer(text=_("{num} track(s)").format(num=track_len))
|
||||
await ctx.send(embed=embed)
|
||||
else:
|
||||
msg = "No tracks."
|
||||
playlist_url = playlists[playlist_name]["playlist_url"]
|
||||
if not playlist_url:
|
||||
embed_title = _("Playlist info for {playlist_name}:\n").format(
|
||||
playlist_name=playlist_name
|
||||
)
|
||||
else:
|
||||
embed_title = _("Playlist info for {playlist_name}:\nURL: {url}").format(
|
||||
playlist_name=playlist_name, url=playlist_url
|
||||
)
|
||||
|
||||
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")
|
||||
async def _playlist_list(self, ctx):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user