Answer the question
In order to leave comments, you need to log in
How to create a track list?
I am writing a music bot, at the moment I encountered a problem, when the "play" command is called, the bot plays music, respectively, this is queued and each track has its own number. But it turned out that part of the code for some reason does not work, and when you enter the command to get the list of tracks "queue", all tracks have the number 1
Code:
@commands.command()
async def queue(self, ctx):
"""Retrieve a basic queue of upcoming songs."""
vc = ctx.voice_client
if not vc or not vc.is_connected():
embed = discord.Embed(title = "", description = "Я не подключен к голосовому каналу.", colour = 0x9370DB)
return await ctx.send(embed = embed)
player = self.get_player(ctx)
if player.queue.empty():
embed = discord.Embed(title = "", description="Очередь пуста.", colour = 0x9370DB)
return await ctx.send(embed = embed)
seconds = vc.source.duration % (24 * 3600)
hour = seconds // 3600
seconds %= 3600
minutes = seconds // 60
seconds %= 60
if hour > 0:
duration = "%d:%02d:%02d" % (hour, minutes, seconds)
else:
duration = "%02d:%02d" % (minutes, seconds)
# Grabs the songs in the queue...
upcoming = list(itertools.islice(player.queue._queue, 0, int(len(player.queue._queue))))
fmt = '\n'.join(f"`{(upcoming.index(_)) + 1}.` [{_['title']}]({_['webpage_url']}) | Запросил: {_['requester']}\n" for _ in upcoming)
embed = discord.Embed(title = f'Очередь для {ctx.guild.name}', description = fmt, colour = 0x9370DB)
embed.set_footer(text = f"{ctx.author}", icon_url = ctx.author.avatar_url)
await ctx.send(embed = embed)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question