feat(commands/voice/queue): add --page

This commit is contained in:
Ryan 2024-12-31 22:18:23 -05:00
parent 64919008a5
commit 7e27c9158b
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3

View File

@ -1,3 +1,5 @@
import math
import arguments import arguments
import commands import commands
import utils import utils
@ -66,6 +68,13 @@ async def queue_or_play(message):
action="store_true", action="store_true",
help="print duration of queued songs", help="print duration of queued songs",
) )
parser.add_argument(
"-p",
"--page",
type=int,
default=1,
help="print the specified page of the queue",
)
if not (args := await parser.parse_args(message, tokens)): if not (args := await parser.parse_args(message, tokens)):
return return
@ -154,15 +163,20 @@ async def queue_or_play(message):
"resumed!", "resumed!",
) )
else: else:
currently_playing = ( args.page = max(
lambda: f"**0.** {'(paused) ' if message.guild.voice_client.is_paused() else ''} {players[message.guild.id].current.format(with_queuer=True)}" min(args.page, math.ceil(len(players[message.guild.id].queue) / 10)), 1
) )
queue_list = lambda: "\n".join( queue_list = lambda: "\n".join(
[ [
f"**{i + 1}.** {queued.format(with_queuer=True, hide_preview=True)}" f"**{i + 1}.** {queued.format(with_queuer=True, hide_preview=True)}"
for i, queued in enumerate(players[message.guild.id].queue) for i, queued in list(enumerate(players[message.guild.id].queue))[
(args.page - 1) * 10 : args.page * 10
]
] ]
) )
currently_playing = (
lambda: f"**0.** {'(paused) ' if message.guild.voice_client.is_paused() else ''} {players[message.guild.id].current.format(with_queuer=True)}"
)
if ( if (
not players[message.guild.id].queue not players[message.guild.id].queue
and not message.guild.voice_client.source and not message.guild.voice_client.source