2

Since today I have a problem with ytdl (all code was working fine a few days ago), I think it's because of the ytdl update,

here is the error:

MinigetError: Status code: 410
    at ClientRequest.<anonymous> (/home/container/node_modules/miniget/dist/index.js:210:27)
    ...

and here is the function

async function runVideo(message, msg, noShift) {
    const server = servers.get(message.guild.id);

    const audioPlayer = createAudioPlayer();

    let player;
    
    // here is the problem
    player = await ytdl(server.currentVideo.url, {
        quality: 'highestaudio'
    })

    const voiceChannel = message.member.voice.channel;
    const connection = getVoiceConnection(message.guild.id);
    const resource = createAudioResource(player, { inlineVolume: true });
    resource.volume.setVolumeLogarithmic(server.currentVol / 100)
    audioPlayer.play(resource);
    
    audioPlayer.on('error', async error => {
        console.log(error)
        if(server.tries >= 3) {
            await message.channel.send(':x: To many fail, disconnecting the bot...').then(() => {
                server.tries = 0
                return connection.destroy()
            })
        } else {
            message.channel.send(`:warning: An error occured, retrying to play the song (tries ${server.tries + 1}/3)...`).then(() => {
                server.tries++;
                return runVideo(message)
            })
        }
    });

    ...
}
Konixy
  • 41
  • 5
  • 3
    [410 Status Code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410) Indicates that the resource you're trying to retrieve has been permanently deleted – Elitezen Dec 17 '21 at 20:10
  • 2
    I've also found that this can indicate the video is age restricted, or cannot be accessed without a login for some other reason. You can work around this by extracting the cookies from your logged in browser setting and adding them to ytdl. An example can be found [at the github repo](https://github.com/fent/node-ytdl-core/blob/master/example/cookies.js). – Levi_OP Feb 02 '22 at 19:48

0 Answers0