FFmpeg with Pycored

I have an event that when someone joins a vc the bot joins that vc and plays an audio. The bot joins the vc but it doesn’t play the audio (with no errors).

This is the event:

async def on_voice_state_update(member, before, after):
    target_channel_id = 989472704249884672 

    if after.channel and after.channel.id == target_channel_id:
        if not bot.voice_clients: 
            voice_channel = await after.channel.connect()

Im running it on Replit.

so the event works perfectly when i run it on visual studio code… but i have no idea how to setup ffmpeg on replit

Is there pkgs.ffmpeg in replit.nix? If not, add it there. This should fix it.
If it did not fix, go to shell, do kill 1 to restart repl

Extra (not necessarily needed):
Also after this, if you feel the voice is too laggy, then try using the opus audio from pycord. For it you would need to install a libopus.so.* file

how can i access replit.nix?

In the file selector, there are 3 dots on the top right corner. Click it and click “show hidden files”. Then you should be able to see the file

well i added it
its still not playing the sound

i added a print statement after voice_channel = await after.channel.connect()

but its not printing it

Can you give the repl link?

1 Like


It seems like you have both pycord and discord together.

  1. So fiirst uninstall discord:
    pip uninstall discord
  2. Then remove discord and replit from pyproject.toml
  3. Then update pycord: poetry update pycord
    (If poetry errors then first pip install requests then run the above)

After all this, kick your bot out of voice channel, leave it yourself, then restart your bot, join channel and IT WORKS!