最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

运维笔记admin8浏览0评论

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

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

我的机器人播放了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
});

没有错误,声音只会在文件末尾切出。

回答如下:

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

发布评论

评论列表(0)

  1. 暂无评论