Node.js 不和谐机器人没有发出声音
我目前正在使用Discord.jsv12(ubuntu20.04,Node.jsv14.0.0),而且我没有播放任何声音的机会 示例代码(voice_connection指定中定义的VoiceConnection实例):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(数
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));
你可以试着用这种方式播放音频文件,我已经测试过了,它适合我