Discord bot node.js linux no sound

I've been trying to get a bot to send sound on Discord, but I can't manage to get it to work. I've copy pasted the same piece of code which worked on Windows on my Arch Linux server, and the bot simply joins, and instantly leaves.

Here is what I have tried :

const fs = require('fs');
client.on('message', msg => {
        var VC = msg.member.voiceChannel;
        if (!VC)
        {
            msg.channel.send('This command only works in a voice channel');
        }
        VC.join().then(connection => 
        {
            const dispatcher = connection.playFile('mysoundfile.mp3');
            dispatcher.on("end", end => {VC.leave()});
        })
}

I just can't figure out what is wrong, and I have done long google researches on that problem.

Thanks.

1 answer

  • answered 2018-11-08 15:34 Svetoslav Petrov

    Usually nodejs takes care about paths on different operating systems, but some paths throw an error. What I would suggest is to use something like:

    const mp3File = path.join(process.cwd(), 'mysoundfile.mp3');
    const dispatcher = connection.playFile(mp3File);