bot.play = (guild, music) => {
let queue = bot.queue.get(guild.id);
let votes = bot.votes.get(guild.id)
if (!music) { queue.voiceChannel.leave();
bot.queue.delete(guild.id);
bot.votes.delete(guild.id);
return queue.textChannel.send( finish`);
}
let music1 = ytdl(music.url);
music1.pipe(fs.createWriteStream('video.mp3'))
let dispatcher= queue.connection.playStream(fs.createReadStream('video.mp3'))
.on('end', () => {
queue.musics.shift();
votes.votes = 0;
votes.voters = [];
setTimeout(() => {
bot.play(guild, queue.musics[0]);
}, 250);
})
.on('progress', (d, total, length) => {
console.log('progress', total / length);
})
.on('error', err => console.error(err));
dispatcher.setVolumeLogarithmic(queue.volume / 100);
queue.textChannel.send(` **${music.title}** now playing`);
我想将音频文件保存在mp3中,并在完成后加入我的频道并播放它。但是,该文件只保存了,什么也没有发生。
答案 0 :(得分:0)
您需要将路径目录设置为绝对路径,例如:
C:/Bot/Musics/video.mp3