【问题标题】:Discord.js voice bot cuts out when playing local mp3 fileDiscord.js 语音机器人在播放本地 mp3 文件时中断
【发布时间】:2020-02-05 01:48:41
【问题描述】:

我的机器人播放 mp3 声音,但在接近尾声时会中断,尤其是短 (

多次重装ffmpeg

client.on('message', message => {
  // Voice only works in guilds, if the message does not come from a guild,
  // we ignore it
  if (!message.guild) return;

    if (message.content === '!sound') {
    // Only try to join the sender's voice channel if they are in one themselves
    if (message.member.voiceChannel) {
      message.member.voiceChannel.join()
        .then(connection => { // Connection is an instance of VoiceConnection
          const dispatcher = connection.playFile('C:/Users/X/Desktop/my-bot/Sounds/SJW2.mp3');

          dispatcher.on("end", end => {connection.disconnect});
        })
        .catch(console.log);
        client.on('end', () => {
  // The song has finished
});

没有错误,声音在文件末尾附近被删掉了。

【问题讨论】:

    标签: node.js discord discord.js voice


    【解决方案1】:

    尝试使用 opus 语音。此外,您的主机的互联网速度会影响它。这可能是由于高延迟

    【讨论】:

    • 解决了这个问题 - 这是 discord.js v10 的一个问题,升级到 v12 解决了它
    猜你喜欢
    • 2021-12-08
    • 1970-01-01
    • 2019-05-05
    • 1970-01-01
    • 2021-07-07
    • 2021-11-22
    • 2021-06-05
    • 2021-11-16
    相关资源
    最近更新 更多