Discord.js语音bot在播放本地mp3文件时会中断

问题描述 投票:0回答:1

我的机器人播放了mp3声音,但声音接近尾声,特别是对于短(<2s)文件。

多次重新安装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个回答
0
投票

尝试使用作品语音。另外,您托管的互联网速度也会影响它。可能是由于高延迟]

© www.soinside.com 2019 - 2024. All rights reserved.