Discord bot node.js linux没有声音

时间:2018-11-08 00:16:03

标签: node.js discord

我一直试图让一个机器人在Discord上发送声音,但是我无法使其正常工作。我已经复制并粘贴了与我的Arch Linux服务器上的Windows相同的代码,然后该bot只需加入并立即退出。

这是我尝试过的:

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()});
        })
}

我只是不知道出什么问题了,我已经在谷歌上做了很长时间的研究。

谢谢。

1 个答案:

答案 0 :(得分:0)

通常,nodejs处理不同操作系统上的路径,但是某些路径会引发错误。我建议使用的是这样的东西:

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