I am trying to host a discord music bot in heroku, but even if it works fine in my local machine, it doesnt seem to be able to find the libopus library deployed.
He
Unfortunately, Heroku can’t send the appropriate voice packets to discord, therefore you must self host or use a vps to use music. Somebody did find a loophole but idk if it was patched but chances are you won’t be able to get music https://i.stack.imgur.com/LWcF4.jpg
I had this issue, and now have a functioning music bot with heroku. Add this buildpack https://github.com/xrisk/heroku-opus.git and then redeploy your bot and restart the dyno. This should fix the error. If that still doesn't work then try adding to the start of your code
if not discord.opus.is_loaded():
# the 'opus' library here is opus.dll on windows
# or libopus.so on linux in the current directory
# you should replace this with the location the
# opus library is located in and with the proper filename.
# note that on windows this DLL is automatically provided for you
discord.opus.load_opus('opus')
I had similar problem. I don't know if it will work for you, but you can give it a try (when I tried to run it on my computer I got an error, but on Heroku it works perfect).
I added this to my script:
import ctypes
import ctypes.util
print("ctypes - Find opus:")
a = ctypes.util.find_library('opus')
print(a)
print("Discord - Load Opus:")
b = discord.opus.load_opus(a)
print(b)
print("Discord - Is loaded:")
c = discord.opus.is_loaded()
print(c)
Remember to put it before anything linked to audio (the best option is to paste it at the beginning).
Source