discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.36k stars 3.97k forks source link

Could not find an Opus module #3097

Closed GuillaumeNachury closed 5 years ago

GuillaumeNachury commented 5 years ago

I'm trying to get my bot working on linux (Linux vpsxxxx.ovh.net 3.16.0-7-amd64 #1 SMP Debian 3.16.59-1 (2018-10-03) x86_64 GNU/Linux) but it seems that I can't play any sound file on this OS. It is working perfectly on my windows machine, so I guess the problem is not into my code.

I'm using this dependencies :

"dependencies": {
    "@google-cloud/text-to-speech": "^0.4.0",
    "cors": "^2.8.5",
    "discord.js": "https://github.com/discordjs/discord.js.git",
    "express": "^4.16.4",
    "ffmpeg-binaries": "^4.0.0",
    "node-opus": "^0.3.1",
    "text-to-mp3": "^1.0.4"
  }

Every time I try to play a file voiceConnection.play('./aaa.mp3'); I get this error

(node:15624) UnhandledPromiseRejectionWarning: Error: Could not find an Opus module! Please install node-opus or opusscript.
    at new OpusStream (/root/quirk/node_modules/prism-media/src/opus/Opus.js:37:13)
    at new Decoder (/root/quirk/node_modules/prism-media/src/opus/Opus.js:140:1)
    at AudioPlayer.playOpusStream (/root/quirk/node_modules/discord.js/src/client/voice/player/BasePlayer.js:79:23)
    at VoiceConnection.play (/root/quirk/node_modules/discord.js/src/client/voice/util/PlayInterface.js:75:28)
    at VoiceConnection.onSessionDescription (/root/quirk/node_modules/discord.js/src/client/voice/VoiceConnection.js:445:29)
    at emitOne (events.js:116:13)
    at VoiceWebSocket.emit (events.js:211:7)
    at VoiceWebSocket.onPacket (/root/quirk/node_modules/discord.js/src/client/voice/networking/VoiceWebSocket.js:187:14)
    at VoiceWebSocket.onMessage (/root/quirk/node_modules/discord.js/src/client/voice/networking/VoiceWebSocket.js:138:19)
    at WebSocket.onMessage (/root/quirk/node_modules/ws/lib/event-target.js:120:16)
(node:15624) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15624) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I don't understand what this 'Please install node-opus or opusscript.' msg means since I do have node-opus as a dep.

Notice : I tried opusscript, but I got another error :

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: spawn /root/quirk/node_modules/ffmpeg-binaries/bin/ffmpeg ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:362:16)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
    at process._tickCallback (internal/process/next_tick.js:181:9)

ffmpeg is installed on my vps :

# ffmpeg -version
ffmpeg version 2.6.9 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
amishshah commented 5 years ago

I just made a change to Discord.js very recently, can you try reinstalling all your modules - especially prism-media - and tell me if this fixes your issue?

GuillaumeNachury commented 5 years ago

I just did a rm -Rf node_modules and gave yarn a run. I still got the error, should a I use a specific branch ?

amishshah commented 5 years ago

Could you try providing an absolute path to the audio file and see if that works?

GuillaumeNachury commented 5 years ago

Yes I already tried that using hardcoded value or via path.join(process.cwd(),"aaaa.mp3");

amishshah commented 5 years ago

That's strange, maybe it's because your FFmpeg is pretty out of date? Could you try uninstalling ffmpeg-binaries, see if that fixes the problem. If it doesn't, try updating FFmpeg on your VPS. Tell me if that still doesn't work and I'll do some more investigation tomorrow.

amishshah commented 5 years ago

Closing due to inactivity

elliopitas commented 4 years ago

i have the same problem opusscript crashes and it doesn't detect @discordjs/opus or node-opus