question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Opus not loaded, only occurs on VPS

See original GitHub issue

Whenever I try to make my music bot join a voice channel with this code:

    elif message.content.startswith(";music join") or message.content.startswith(";music j") or message.content.startswith(";m j"):
        try:
            await create_voice_client(message.author.voice_channel)
            await bot.send_message(message.channel, "I joined your voice chat!")
        except discord.errors.InvalidArgument:
            await bot.send_message(message.channel, "You don't seen to be in a voice channel :/")
        except Exception as error:
            await bot.send_message(message.channel, "Error: **{}**".format(error))

It works while running on my PC, but the same code gives me this error on my VPS:

Ignoring exception in on_message
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/discord/client.py", line 307, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "Musicbot.py", line 697, in on_message
    await create_voice_client(message.author.voice_channel)
  File "Musicbot.py", line 38, in create_voice_client
    voice = await bot.join_voice_channel(channel)
  File "/usr/local/lib/python3.5/dist-packages/discord/client.py", line 3209, in join_voice_channel
    voice = VoiceClient(**kwargs)
  File "/usr/local/lib/python3.5/dist-packages/discord/voice_client.py", line 230, in __init__
    self.encoder = opus.Encoder(48000, 2)
  File "/usr/local/lib/python3.5/dist-packages/discord/opus.py", line 197, in __init__
    raise OpusNotLoaded()
discord.opus.OpusNotLoaded

And I can’t figure out what’s wrong

When I put

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')

at the start of my file, the bot does not start and tells me it didn’t find the specified directory. Any idea?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
gerdmuehlbergercommented, Apr 29, 2020

@Emad-Fussi

Thanks, I tried deploying my bot on heroku and in my case your solution fixed the issue.

9reactions
Omd-5commented, Nov 8, 2019

this Buildpack: https://github.com/xrisk/heroku-opus.git will fix it 100%.

Read more comments on GitHub >

github_iconTop Results From Across the Web

discord.py - Command raised an exception: OpusNotLoaded
So you are sure that an exception will be raised if it's not loaded properly and know where to look immediatly. If an...
Read more >
Linux Guide - NadekoBot
Follow the following few steps only if you're migrating from v3. If not, skip to installation instructions. Use the new installer script: cd...
Read more >
changelog.txt - LIVE555.COM
These cameras support SRTP only when the RTSP connection to the camera is over a TLS connection (something that our RTSP client code...
Read more >
Step By Step Scratch install Goautodial V4 with FQDN
This guide is more for the people that can not use the ISO and/or FQDN, when hosting Goautodial on a server that can...
Read more >
How To Install the Ampache Music Streaming Server on ...
This means that your Ampache server will only be available via HTTPS. This option is the more secure and will not affect how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found