【发布时间】:2019-09-14 18:02:49
【问题描述】:
通过机器人,我正在尝试使用 discord.js、ffmpeg 和 opusscript 在音频通道中播放音频文件 (mp3)。
基本上就是这样:
bot.on('message', msg => {
if (msg.author.bot) return;
if (msg.content.substring(0,3) == "fp!") {
var audioID = msg.content.substring(3,msg.length);
var channel = msg.member.voiceChannel;
if (!channel) msg.channel.send("T'es pas dans un vocal, con.");
else {
msg.member.voiceChannel.join()
.then((connection) => {
connection.playFile(`./audios/${audioID}.mp3`);
});
}
}
return;
});
因此,音频播放,但它在结束前停止(例如,对于 5 秒的音频文件,它在 3 秒后停止)。机器人停留在频道中,我可以再次播放,但对于我的所有文件,它会在结束前停止。 我该如何解决?
【问题讨论】:
标签: node.js audio discord.js