Discord Music Bot подключается к голосовому каналу, горит зеленым, но не имеет звука. Хорошо работал за 2 недели до этого. В консоли ошибок нет

Я написал бота с помощью node.js. Я использовал пример Crawl для его музыкального бота. Я все делал аналогично ему. После того, как я закончил сборку, все заработало. Все остальные команды и команда play. Но теперь, через 2 недели, бот подключается к голосовому каналу, горит зеленым светом, но звука нет. Я обновил ffmpeg, @discordjs/opus, ffmpeg-static и загрузил законченную версию с ffmpeg, но у бота по-прежнему нет звука. В queue, volume, nowplaying, skip, shuffle, loop все работает. Но после того, как я получил видео или плейлист с командой воспроизведения, бот только загорается зеленым светом, но не имеет звука. Таким образом, бот определенно получает URL-адрес, получает видео, получает все, что ему нужно для воспроизведения. Но после присоединения он не использует информацию для игры. Также он не покидает голосовой канал после того, как песня должна закончиться.

function play(guild, song) {

  try {

    const ServerMusicQueue = queue.get(guild.id);

    if (!song) {

      ServerMusicQueue.textchannel.send(`???? Queue ended and left the Voicechannel!`).then(message => message.delete(6000));

      ServerMusicQueue.voiceChannel.leave()

      queue.delete(guild.id)
      return;
    }

    const dispatcher = ServerMusicQueue.connection.playStream(ytdl(song.url, { filter: 'audioonly', quality: 'highestaudio', highWaterMark: 1 << 25 }))
      .on('end', () => {

        var loopset = JSON.parse(fs.readFileSync("./rqs/loopset.json", "utf8"))

        if (!loopset[message.guild.id]) {
          loopset[message.guild.id] = {
            loopset: config.loopset
          }
        }

        var loop2 = loopset[message.guild.id].loopset;

        if (loop2 === "true") {
          play(guild, ServerMusicQueue.songs[0])
          return;
        }

        ServerMusicQueue.songs.shift()

        play(guild, ServerMusicQueue.songs[0])

      })
      .on('error', error => {
        console.error(error)
      });

    dispatcher.setVolumeLogarithmic(ServerMusicQueue.volume / 5);

    ServerMusicQueue.textchannel.send(`???? Start playing: **${song.title}**`).then(message => message.delete(8000));

  } catch (error2) {

    console.log(error2)

  }

}
async function handleVideo(video, message, voiceChannel, playlist = false) {

                    const ServerMusicQueue = queue.get(message.guild.id)

                    const song = {
                        id: video.id,
                        title: Util.escapeMarkdown(video.title),
                        url: `https://www.youtube.com/watch?v=${video.id}`,
                        duration: video.duration,
                        requested: message.author.username
                    };

                    if(!ServerMusicQueue) {
                        const queueConstruct = {
                            textchannel: message.channel,
                            voiceChannel: voiceChannel,
                            connection: null,
                            songs: [],
                            volume: 5,
                            playing: true,
                        };

                        queue.set(message.guild.id, queueConstruct);

                        queueConstruct.songs.push(song)

                        try {

                        var connection = await voiceChannel.join()

                        queueConstruct.connection = connection;

                        play(message.guild, queueConstruct.songs[0])

                        var loopset = JSON.parse(fs.readFileSync("./rqs/loopset.json", "utf8"))

                        if(!loopset[message.guild.id]){
                                loopset[message.guild.id] = {
                                    loopset: config.loopset
                            }
                        }

                        var loop2 = loopset[message.guild.id].loopset;

                            if(loop2 === "true") {

                            loopset[message.guild.id] = {
                                loopset: "false"
                            }

                            fs.writeFile("./rqs/loopset.json", JSON.stringify(loopset), (err) => {
                                if (err) console.log(err)
                            });
                        }

                        } catch (error) {
                            console.error(`Voicechannel join: ${error}`)
                            queue.delete(message.guild.id);
                            message.channel.send("Error with joining the Voicechannel!").then(message => message.delete(5000));
                            message.delete(4000).catch(console.error);
                            return;
                        }

                    } else {

                        ServerMusicQueue.songs.push(song);
                        if(playlist) return undefined;
                        else return message.channel.send(`???? **${song.title}** has been added to the queue!`).then(message => message.delete(5000));

                    }

                    return;

                    }

package.json

"dependencies": {
    "@discordjs/opus": "^0.3.2",
    "bufferutil": "^4.0.1",
    "colors": "^1.4.0",
    "discord.js": "^11.6.4",
    "discord.js-commando": "^0.10.0",
    "discord.js-musicbot-addon": "^13.9.1",
    "discordjs-prompter": "^1.3.1",
    "ffmpeg-static": "^4.2.2",
    "file-system": "^2.2.2",
    "html-entities": "^1.3.1",
    "m3u8stream": "^0.7.0",
    "miniget": "^1.7.0",
    "ms": "^2.1.2",
    "node-opus": "^0.3.3",
    "npm": "^6.14.5",
    "simple-youtube-api": "^5.2.1",
    "sqlite": "^3.0.3",
    "sqlite3": "^4.1.0",
    "superagent": "^5.2.2",
    "yt-search": "^1.1.2",
    "ytdl-core": "^2.1.3"
  }

person FeX    schedule 29.05.2020    source источник


Ответы (1)


Попробуйте получить ytdl-core, это может решить проблемы.

npm i ytdl-core

Если это не решит проблему, попробуйте получить Discord-YTDL-Core (убедитесь, что у вас установлен ytdl-core)

npm i discord-ytdl-core
person Bombo43453    schedule 08.06.2021