Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 不和谐机器人没有发出声音_Node.js_Discord.js - Fatal编程技术网

Node.js 不和谐机器人没有发出声音

Node.js 不和谐机器人没有发出声音,node.js,discord.js,Node.js,Discord.js,我目前正在使用Discord.jsv12(ubuntu20.04,Node.jsv14.0.0),而且我没有播放任何声音的机会 示例代码(voice_connection指定中定义的VoiceConnection实例): const ytdl=require(“ytdl核心不一致”); ... const data=wait ytdl(/*一些youtube url*/,{filter:“audioonly”}); const dispatcher=voice_connection.play(数

我目前正在使用Discord.jsv12(ubuntu20.04,Node.jsv14.0.0),而且我没有播放任何声音的机会

示例代码(voice_connection指定中定义的VoiceConnection实例):

const ytdl=require(“ytdl核心不一致”);
...
const data=wait ytdl(/*一些youtube url*/,{filter:“audioonly”});
const dispatcher=voice_connection.play(数据);
我已安装
ffmpeg@0.0.4
opusscript@0.0.7
@discordjs/opus@0.3.2
ffmpeg-static@4.0.1

此外,在侦听dispatcher的
debug
事件时,我在运行代码大约10秒后收到以下错误:

Error: ffmpeg stream: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:92:16) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}
最终目标是:解决机器人无法播放任何声音、本地文件或远程URL的问题。

const channel=message.member.voice.channel;
channel.join().then(连接=>{
const dispatcher=connection.play(path.join(uu dirname+'path.mp3');
dispatcher.on('speaking',speaking=>{
如果(!正在讲话)频道。离开();
});
}).catch(err=>console.log(err));
你可以试着用这种方式播放音频文件,我已经测试过了,它适合我