Cookie header used in request, but unable to find YouTube identity token

1k Views Asked by At

I have made this JavaScript discord music bot using distube, ytdl-core, discord.js, ffmpeg-static. This bot was perfectly running but from past 3-4 days I am continuously getting this error:

Cookie header used in request, but unable to find YouTube identity token

I am getting this error only with play command and every other command works great.

enter image description here

1

There are 1 best solutions below

0
On

Yes, that's an ytdl-core error when bot tries to get the song and the cookie is used but the library cannot find the "identity token" so, you can prevent it with a Javascript try/catch:

Example with distube library:

const song = args.join(' ')

try {
  player.play(message, song)
} catch {
  console.log('Error trying to play a song.')
  message.reply({ content: ':x: Sorry, an unexpected error has ocurred try to playing that song.' })
}

// DISTUBE.JS v2^
// DISCORD.JS v13.2
// MADE FOR A TYPICAL BOT STRUCTURE USING DISCORD.JS