Reputation: 11
I'm programming a discord bot using discord.js. I want to make a random sound player! What am I doing wrong? Can you help me?
case 'ps':
var voiceChannel = message.member.voiceChannel
voiceChannel.join().then(connection => {
number = 5;
var random = Math.floor (Math.random() * (number - 1 + 1 )) + 1;
var rs = ( {files: [__dirname + '/Library/folder/' + "sound" + " (" + random + ")" + ".jpg"]} );
const dispatcher = connection.playFile(rs);
dispatcher.on('end', end => voiceChannel.leave());
})
break;
There aren't any errors in terminal.
Upvotes: 1
Views: 413
Reputation: 24
The problem is, you are trying to get an Audio file with the extension ".jpg" in :
var rs = ( {files: [__dirname + '/Library/folder/' + "sound" + " (" + random + ")" + ".jpg"]} );
replace .jpg
with an audio extension, .mp3, .wav, etc...
Upvotes: 0
Reputation: 5174
Your issue would be the fact you're trying to get an image, not an audio file.
replace .jpg
in var rs = ( {files: [__dirname + '/Library/folder/' + "sound" + " (" + random + ")" + ".jpg"]} );
to whatever audio file extension you're using: mp3
, wav
, etc.
Upvotes: 3