Голосовой бот Discord.js отключается при воспроизведении локального mp3 файла - PullRequest
0 голосов
/ 07 октября 2019

Мой бот воспроизводит звук в формате mp3, но в конце он обрывается, особенно с короткими (<2s) файлами. </p>

Много раз переустанавливал 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
});

Нет ошибок, звучит простовырезать в конце файла.

1 Ответ

0 голосов
/ 11 октября 2019

Попробуйте использовать опус голос. Кроме того, скорость интернета вашего хостинга влияет на это. Вероятно, из-за высокой задержки

...