I'm new to Discord.js and I'm trying to have the bot join a voice channel and play an audio file on my computer. I have been following this guide: https://discord.js.org/#/docs/main/stable/topics/voice . Here is the Index.js page:
Colesbot.on('message', message=>{
if (message.content === '/join') {
// Only try to join the sender's voice channel if they are in one themselves
if (message.member.voiceChannel) {
message.member.voiceChannel.join().then(connection => {
message.reply('I have successfully connected to the channel!');
// To play a file, we need to give an absolute path to it
const dispatcher = connection.playFile('C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\Assets\Glory.mp3');
dispatcher.on('end', () => {
// The song has finished
console.log('Finished playing!');
});
dispatcher.on('error', e => {
// Catch any errors that may arise
console.log(e);
});
dispatcher.setVolume(0.5); // Set the volume to 50%
}).catch(console.log);
} else {
message.reply('You need to join a voice channel first!');
}
}
});
exports.run = (client, message, args) => {
let user = message.mentions.users.first || message.author;
}
FFMPEG is installed and I have set the environment path for it. When I type FFMPEG in the command line I get the proper response.
Some have said I need to install the ffmpeg binaries but when I run npm install ffmpeg-binaries I get an error message that is here
So then I tried installing an older version and I'm now using [email protected] but when I type /join I get the error
[ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object