Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.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
Javascript Discord js音乐机器人不';我不能演奏音乐_Javascript_Discord_Discord.js_Bots - Fatal编程技术网

Javascript Discord js音乐机器人不';我不能演奏音乐

Javascript Discord js音乐机器人不';我不能演奏音乐,javascript,discord,discord.js,bots,Javascript,Discord,Discord.js,Bots,我正在尝试为我的discord机器人制作音乐功能。老实说,我从YouTube视频中获得了代码,但它对我不起作用。没有错误或其他什么,它只是不能播放音乐。有人能帮忙吗 const ytdl=require('ytdl-core'); bot.on('message',async(msg)=>{ 如果(msg.author.bot)返回; 如果(!msg.content.startsWith(prefix))返回; const args=msg.content.substring(前缀.length

我正在尝试为我的discord机器人制作音乐功能。老实说,我从YouTube视频中获得了代码,但它对我不起作用。没有错误或其他什么,它只是不能播放音乐。有人能帮忙吗

const ytdl=require('ytdl-core');
bot.on('message',async(msg)=>{
如果(msg.author.bot)返回;
如果(!msg.content.startsWith(prefix))返回;
const args=msg.content.substring(前缀.length).split(“”);
if(msg.content.startsWith(`${prefix}play`){
const voiceChannel=msg.member.voice.channel;
如果(!语音频道)
返回msg.channel.send('您需要在语音频道');
const permissions=voiceChannel.permissions for(msg.client.user);
如果(!permissions.has('CONNECT'))
返回msg.channel.send(
“我没有连接到语音频道的权限。帮助。”
);
如果(!permissions.has('SPEAK'))
返回msg.channel.send(
“我没有在语音频道讲话的权限”
);
试一试{
var connection=wait voiceChannel.join();
}捕获(错误){
返回msg.channel.send(
`连接到语音频道${error}时出错`
);
}
const dispatcher=连接
.play(ytdl(args[1]))
.on('finish',()=>{
voiceChannel.leave();
})
.on('错误',(错误)=>{
msg.channel.send('出现错误:'+错误);
});
调度员:设置音量音量(5/5);
}else if(msg.content.startsWith(`${prefix}stop`){
如果(!msg.member.voice.channel)
返回msg.channel.send('您需要在语音频道中才能停止bot');
msg.member.voice.channel.leave();
返回未定义;
}
});

是否安装了
ffmpeg static
@discordjs/opus
?是的。我已经安装了它,但仍然没有工作。等等不。@Jakye当我尝试安装@discordjs/opus时,出现了一个错误:TypeError:options.callback不是一个函数