K
K
Kir Mozor2022-02-12 17:41:14
Python
Kir Mozor, 2022-02-12 17:41:14

Command raised an exception: TypeError: a bytes-like object is required, not 'coroutine'. How to fix?

My partner and I are writing a discord bot to listen to music from Yandex.Music: Our GitHub project
We need to make the bot listen to music without downloading the track, that is, broadcast it. They helped us with this by providing this solution: View code
But, unfortunately, our knowledge is not enough to adapt this code to our bot. We tried to adapt it like this, but it didn't help because the error is:


Command raised an exception: TypeError: a bytes-like object is required, not 'coroutine'


Our code:
@bot.command()
async def playGodProgramming(ctx):
    channel = ctx.message.author.voice.channel
    if not channel:
        await ctx.send("Вы не подключены к голосовому чату :(")
        return
    voice = get(bot.voice_clients, guild=ctx.guild)
    if voice and voice.is_connected():
        await voice.move_to(channel)
    else:
        voice = await channel.connect()

    url = extract_direct_link_to_track(37971706)
    blob = get_track_as_blob_by_url(url)
    get_memcached_track(blob)

    source = FFmpegPCMAudio(blob.read()) #Error
    player = voice.play(source)
    #Все методы из кода были перенесены без изменений

Please help us. We don't know what to do anymore

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LXSTVAYNE, 2022-02-12
@150_Kirill_150

The blob.read() function returns a coroutine, obviously you need to wait for it.
source = FFmpegPCMAudio(await blob.read())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question