discordjs / discord.js

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

Errors with voiceConnectionObject.playXYZ functions #418

Closed sambeyer closed 8 years ago

sambeyer commented 8 years ago

Hi,

I'm trying to get my bot to play audio, however regardless of which play function it uses, my code breaks. Currently I have:

bot.voiceConnection.playFile("Documents/projects/DiscordBots/SoundCloudBot/intro.wav", {volume:0.25});

I've also tried using code found here (using both playRawStream and playFile). The same error occurs.

Here's the error:

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

Error: spawn help ENOENT
    at exports._errnoException (util.js:870:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)

EDIT: The problem was I hadn't installed ffmpeg properly. I don't get that error anymore.

However the problem persists in a different form. I still can't get anything to play. Everything else happens which should, apart from the bot actually playing anything.

mnlkrs commented 8 years ago

ENOENT is an abbreviation for Error no ENTry. In other words your path is faulty. Either give it an absolute path C:/Users/sambeyer/Documents/projects/DiscordBots/SoundCloudBot/intro.wav or the path relative to your root, so if you execute your file in /SoundCloudBot/youfile.js the relative path to intro would simply be intro.wav

sambeyer commented 8 years ago

Hey, thanks for your help, I was wondering what ENOENT meant.

Unfortunately I'm still having the same issue having tried using both the absolute path and the relative path.

mnlkrs commented 8 years ago

I'm guessing it's not finding ffmpeg then. Follow the steps posted here https://github.com/hydrabolt/discord.js/issues/415

sambeyer commented 8 years ago

That fixed it!! I hadn't installed it properly.

I'm still having issues, as I've edited above. Now just no sound is playing.

mnlkrs commented 8 years ago

All voice-related problems should be resolved if you followed the mentioned steps and your code is correct.

Again, to check if you did everything properly..:

1.) Go to your console and type ffmpeg -version. Does it recognize ffmpeg?

2.) Go to your console and type python --version Everything above 2.x.x is not supported

3.) Go to your project folder and reinstall discord.js. Do you get any errors? node-gyp errors are related to missing C++ build tools.

4.) If all this doesn't fail and you still don't get sound make sure your bot has permissions to speak and is not muted.

sambeyer commented 8 years ago

That's fixed it!! Than you so much!

I installed the appropriate version of Python as suggested.

The problem persisted and as you suggested I reinstalled discord.js and found it was giving node-gyp errors as predicted. In an effort to fix these I started using Visual Studio 2015. There were fixes using Visual Studio I found for each error encountered. The bot works perfectly now!!

Again thanks heaps, I'm absolutely stoked.