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.

Cannot get voiceChannel playfile() example to work

See original GitHub issue

With discord.js@9.2.0, I’m doing:

var Discord = require('discord.js');
var bot = new Discord.Client();
bot.login("token").then().catch(err => console.log(err));

bot.on('ready', (message) => {
  var voiceChannel = bot.channels.filter(g => {
    return g.type == 'voice' && g.name == 'General';
  }).first();

  voiceChannel.join()
   .then(connection => {
     console.log('playing');
     const dispatcher = connection.playFile('sound.mp3');
   })
   .catch(err => console.log(err));

});

The bot correctly joins the audio channel, but the ‘playing’ message is never displayed nor audio played.
I’m getting this output after 15 seconds:

Error: Connection not established within 15 seconds.
    at Array.client.setTimeout (/home/v/tjs/node_modules/discord.js/src/client/voice/ClientVoiceManager.js:121:43)
    at Timeout.setTimeout (/home/v/tjs/node_modules/discord.js/src/client/Client.js:163:16)
    at tryOnTimeout (timers.js:232:11)
    at Timer.listOnTimeout (timers.js:202:5)

Is this the new correct way of doing this ? Code for playing sample is taken from new documentation.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
loic-pryvcommented, Aug 14, 2019

@tuneitbaby it’s a bit late but here is the answere message.member.voiceChannel.join()

2reactions
vikbezcommented, Sep 13, 2016

The reason was firewall; on audio chat join, a UDP connection is done for audio (on port 52710 for me) firewall was blocking, connection never made, .then() code never executed etc etc. Hope this will help someone some day 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

discord.js not playing audio file - javascript - Stack Overflow
You can use the module path (no need to download) and the global __dirname to get the absolute path. const dispatcher = connection.playFile( ......
Read more >
Calling VoiceClient::playFile second time on the same client ...
It happens after you wait for a while and call it again, as long as you use the same client without leaving the...
Read more >
Discord JS - Playing Audio in a Voice Channel ... - YouTube
In this video we go over how to get your bot to join a voice channel and how to play an audio file...
Read more >
How Do I Troubleshoot Voice Chat Issues in Rocket League?
To use Voice Chat, plug in a headset into the Switch's audio jack or USB-C port. If you're using a compatible headset and...
Read more >
discord.js v13 detect if mentioned user is not in a voice channel
To check who is in a specific voice channel, use VoiceChannel.members ... I get an error "voice.join() is not a function" on discord.js...
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