Discord.js bot 加入然后离开

时间:2021-04-11 05:01:36

标签: javascript discord discord.js bots ytdl

我构建了一个 discord.js bot,当有人使用它的命令时它会加入,但它只有在视频的浏览量高时才有效,我尝试使用未列出的 YouTube 视频、我上传的一些视频和低浏览量的视频,但事实并非如此工作,它只是加入语音通道然后离开。

 if (message.content == "!sodium") {
     if (!message.member.voice.channel) return message.reply("You have to be in a voice channel");
     message.member.voice.channel.join().then(VoiceConnection => {
         VoiceConnection.play(ytdl("https://youtu.be/30p-iRH9z2c")).on("finish", () => 
         VoiceConnection.disconnect());
         message.reply("started...");
     }).catch(e => console.log(e))
 };

1 个答案:

答案 0 :(得分:0)

我通过添加 { filter: 'audioonly' } 解决了这个问题。