Cannot get voiceChannel playfile() example to work
See original GitHub issueWith 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:
- Created 7 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tuneitbaby it’s a bit late but here is the answere
message.member.voiceChannel.join()
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 🎉