@Oh_noo2195

Как сделать очередь воспроизведения песен у дискорд бота?

Как мне реализовать поочередное воспроизведение песен.То есть при добавлении новой песни командой play, она ждет пока закончится предыдущая и потом начинается воспроизведение следующей.

вот моя команда play
@bot.command(name='play')
async def play(ctx, url: str):
    if ctx.author.voice is None:
        embed = discord.Embed(title=f'', description='подключись к каналу', color='ff0000')
        embed.set_footer(text=f'ПоНяЛ?')
        bot_msg = await ctx.send(embed=embed)
        await asyncio.sleep(15)
        await bot_msg.delete()
    voice_channel = ctx.author.voice.channel        
    if ctx.voice_client is None:
        await voice_channel.connect()
    else:
        await ctx.voice_client.move_to(voice_channel)
    ctx.voice_client.stop()
    FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
    YDL_OPTIONS = {'format':"bestaudio", 'noplaylist': True, 'default_search': 'auto'}

    vc = ctx.voice_client

    with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
        info = ydl.extract_info(url, download=False)
        if 'entries' in info:
            url2 = info['entries'][0]["formats"][0]
        elif 'formats' in info:
            url2 = info["formats"][0]
        url = info["webpage_url"]
        stream_url = url2["url"]
        source = await discord.FFmpegOpusAudio.from_probe(stream_url, **FFMPEG_OPTIONS)
        vc.play(source)
  • Вопрос задан
  • 487 просмотров
Пригласить эксперта
Ваш ответ на вопрос

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

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