播放诸如this one之类的大约5秒钟的链接时,该漫游器可以正常工作,它会播放音频并随后对命令做出响应。
播放更长的时间后,机器人似乎无法响应命令,也不会播放音频。它不适用于代码中的YouTube链接,并且在命令提示符下也不会出现错误。
if (message.member.voiceChannel) {
if(command === `${prefix}join`){
message.member.voiceChannel.join()
.then(connection => {
message.reply('Connected');
let stream = ytdl('https://www.youtube.com/watch?v=Rq2vdkfjaMg', { filter : 'audioonly' }); //When joins plays a small entry sound.
let dispatcher = connection.playStream(stream, streamOptions); //Putting a longer length clip doesnt work.
})
.catch(console.error);
} else if(command === `${prefix}leave`){
message.member.voiceChannel.leave()
} else if(command === `${prefix}play`){
message.member.voiceChannel.join()
.then(connection => {
let stream = ytdl(args.toString(), { filter : 'audioonly' }); //args = youtube link
let dispatcher = connection.playStream(stream, streamOptions);
dispatcher.on('end', () => {
message.member.voiceChannel.leave();
})
})
.catch(console.error);
}
} else {
message.reply('You need to join a voice channel first!');
}