Как сделать воспроизведение музыки по кругу?

Всем добрый день! Можно ли как-то сделать воспроизведение музыки по кругу? Просто постоянно вбивать /p [ссылка_на_видео] не особо удобно. Хотелось бы сделать зацикливание песни. Как это реализовать?
Прикрепляю исходник кода, при помощи которого происходит стандартное воспроизведение:
@Bot.command(aliases = ['p', 'PLAY'])
async def play(ctx, url):
    global voice

    channel = ctx.message.author.voice.channel	
    voice = get(Bot.voice_clients, guild = ctx.guild)	

    song_there = os.path.isfile('song.mp3')

    if voice and voice.is_connected():	
        await voice.move_to(channel)	
    else:	
        voice = await channel.connect()
    try:
        if song_there:
            os.remove('song.mp3')
            print('[logs] Старый файл успешно удалён')
    except PermissionError: 
        print('[logs] Не удалось удалить файл. Неизвестная причина...')

    voice = get(Bot.voice_clients, guild = ctx.guild)
    ydl_opts = {
        'format' : 'bestaudio/best',
        'postprocessors' : [{
            'key' : 'FFmpegExtractAudio',
            'preferredcodec' : 'mp3',
            'preferredquality' : '320'
        }],
    }

    with youtube_dl.YoutubeDL(ydl_opts) as ydl:     
        print ('[logs] Начинаю загрузку музыки...')
        embed = discord.Embed(description = '*Жди - готовлю к воспроизведению твой трек...*')
        await ctx.send(embed = embed)
        ydl.download([url])

    for file in os.listdir('./'):
        if file.endswith('.mp3'):
            name = file
            os.rename(file, 'song.mp3')
    voice.play(discord.FFmpegPCMAudio('song.mp3'), after = lambda e: print(f'{name}, музыка закончила своё проигрывание'))
    nname = name.rsplit('-', maxsplit = 1)

    embed = discord.Embed(description = f' __Сейчас играет:__ **{nname[0]}**', color = 0x428325)
    embed.set_footer(text = "supports by quantprod")
    await ctx.send(embed = embed)

    await Bot.join_voice_channel(channel)
  • Вопрос задан
  • 116 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы