mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Audio] Fix issue on audiostats command when more than 20 servers to display (#2533)
* Update audio.py * Fix of pages counter.
This commit is contained in:
parent
0652dd344b
commit
ad06b0e723
@ -547,8 +547,8 @@ class Audio(commands.Cog):
|
|||||||
"""Audio stats."""
|
"""Audio stats."""
|
||||||
server_num = len([p for p in lavalink.players if p.current is not None])
|
server_num = len([p for p in lavalink.players if p.current is not None])
|
||||||
total_num = len([p for p in lavalink.players])
|
total_num = len([p for p in lavalink.players])
|
||||||
server_list = []
|
|
||||||
|
|
||||||
|
msg = ""
|
||||||
for p in lavalink.players:
|
for p in lavalink.players:
|
||||||
connect_start = p.fetch("connect")
|
connect_start = p.fetch("connect")
|
||||||
connect_dur = self._dynamic_time(
|
connect_dur = self._dynamic_time(
|
||||||
@ -558,40 +558,40 @@ class Audio(commands.Cog):
|
|||||||
if "localtracks/" in p.current.uri:
|
if "localtracks/" in p.current.uri:
|
||||||
if p.current.title == "Unknown title":
|
if p.current.title == "Unknown title":
|
||||||
current_title = p.current.uri.replace("localtracks/", "")
|
current_title = p.current.uri.replace("localtracks/", "")
|
||||||
server_list.append(
|
msg += "{} [`{}`]: **{}**\n".format(
|
||||||
"{} [`{}`]: **{}**".format(
|
|
||||||
p.channel.guild.name, connect_dur, current_title
|
p.channel.guild.name, connect_dur, current_title
|
||||||
)
|
)
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
current_title = p.current.title
|
current_title = p.current.title
|
||||||
server_list.append(
|
msg += "{} [`{}`]: **{} - {}**\n".format(
|
||||||
"{} [`{}`]: **{} - {}**".format(
|
|
||||||
p.channel.guild.name, connect_dur, p.current.author, current_title
|
p.channel.guild.name, connect_dur, p.current.author, current_title
|
||||||
)
|
)
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
server_list.append(
|
msg += "{} [`{}`]: **[{}]({})**\n".format(
|
||||||
"{} [`{}`]: **[{}]({})**".format(
|
|
||||||
p.channel.guild.name, connect_dur, p.current.title, p.current.uri
|
p.channel.guild.name, connect_dur, p.current.title, p.current.uri
|
||||||
)
|
)
|
||||||
)
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
server_list.append(
|
msg += "{} [`{}`]: **{}**\n".format(
|
||||||
"{} [`{}`]: **{}**".format(
|
|
||||||
p.channel.guild.name, connect_dur, _("Nothing playing.")
|
p.channel.guild.name, connect_dur, _("Nothing playing.")
|
||||||
)
|
)
|
||||||
)
|
|
||||||
if server_num == 0:
|
if total_num == 0:
|
||||||
servers = _("Not connected anywhere.")
|
return await self._embed_msg(ctx, _("Not connected anywhere."))
|
||||||
else:
|
servers_embed = []
|
||||||
servers = "\n".join(server_list)
|
pages = 1
|
||||||
embed = discord.Embed(
|
for page in pagify(msg, delims=["\n"], page_length=1500):
|
||||||
|
em = discord.Embed(
|
||||||
colour=await ctx.embed_colour(),
|
colour=await ctx.embed_colour(),
|
||||||
title=_("Playing in {num}/{total} servers:").format(num=server_num, total=total_num),
|
title=_("Playing in {num}/{total} servers:").format(
|
||||||
description=servers,
|
num=server_num, total=total_num
|
||||||
|
),
|
||||||
|
description=page,
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
em.set_footer(text="Page {}/{}".format(pages, (math.ceil(len(msg) / 1500))))
|
||||||
|
pages += 1
|
||||||
|
servers_embed.append(em)
|
||||||
|
|
||||||
|
await menu(ctx, servers_embed, DEFAULT_CONTROLS)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user