Youtube Cookies
YouTube sometimes asks Drako Bot to sign in before it can play a song. Adding a YouTube cookies file lets the bot retry using a signed-in YouTube session.
This setup is optional. If YouTube playback already works, you can leave it as it is.
Before you start
You will need:
A computer with Chrome or Firefox.
A Google account that can sign in to YouTube.
Access to your bot's files, through your hosting panel's file manager or the computer running DrakoBot.
The ability to restart your bot.
This setting applies to the whole bot installation. It must be configured in the bot's files; it is not available in the DrakoBot dashboard.
Keep your cookies private. The exported file contains sign-in information. Treat it like a password: never post it in Discord, attach it to a support ticket, or upload it to GitHub.
Install a cookie exporter
Choose the instructions for your browser. Install the extension in a normal browser window first.
Install Get cookies.txt LOCALLY.
Open Chrome's menu and select Extensions → Manage extensions.
Find Get cookies.txt LOCALLY and select Details.
Turn on Allow in incognito.
See Chrome's extension instructions if you need help finding this option.
Install cookies.txt.
Open Add-ons and themes → Extensions and select cookies.txt.
Find Run in Private Windows and select Allow.
See Firefox's private browsing instructions if you need help finding this option.
Export your YouTube cookies
Close any existing incognito or private windows, then open a new one from your browser's menu.
Visit YouTube and sign in.
In that same tab, open youtube.com/robots.txt. A page of plain text is expected. Keep this as your only private tab.
Open the cookie exporter from your browser's extensions menu.
Export cookies for youtube.com only. If asked for a format, choose Netscape cookies.txt. Avoid the option to export every website's cookies.
Save the downloaded file as
youtube-cookies.txt.Close the private window immediately. Do not sign out first or restore that private session later.
This follows the yt-dlp YouTube export guide. DrakoBot uses yt-dlp for YouTube playback.
yt-dlp warns that using a signed-in account can result in account restrictions. Use cookies only when needed, and consider a separate account. See the account guidance.
Upload the file to your bot
Open your bot's main folder: the folder containing package.json and config.
Open the existing config folder and upload or move youtube-cookies.txt into it. If your bot runs on a hosting service, use that service's private file manager or SFTP connection.
Your files should look like this:
DrakoBot/
├── package.json
└── config/
├── youtube-cookies.txtCheck that the filename is exactly youtube-cookies.txt, without an extra .txt at the end. The file must be on the machine running the bot, not just in your computer's Downloads folder.
The bot needs permission to read and write this file. On a Linux host, the account running the bot should own it; permissions of 600 allow only that owner to read and write it. Ask your host to check ownership if you are unsure.
Update the music configuration
Open config/modules/music.yml and find YouTubeCookiesFile inside the existing Music section.
Set it to:
Music:
YouTubeCookiesFile: "config/youtube-cookies.txt"This is already the default in current configurations. If it matches, leave it as it is.
Edit only this setting. Keep your other music settings and do not add a second Music: section. Use spaces for indentation, with YouTubeCookiesFile lined up with settings such as Enabled.
Restart and try a song
Save
music.ymland restart DrakoBot using your usual hosting panel or startup method.Join a Discord voice channel where the bot can play music.
Run
/playand paste a direct YouTube video link intoquery. Try the link that previously failed, provided it is within your server's song-length limit.
DrakoBot tries YouTube without cookies first. If retrieving a video's details or playable audio fails, it can retry with your file. You do not need a separate Discord command to enable cookies.
If it still does not work
The exporter is missing in the private window
Check Allow in incognito in Chrome or Run in Private Windows → Allow in Firefox.
The bot still asks for sign-in or cannot play
Confirm the upload location, filename, configured path, and file permissions. Restart after changing the configured path.
You see “YouTube is unavailable with the configured cookies”
The cookie retry failed. Export a fresh file using step 2 and replace the uploaded copy.
You exported JSON or copied a cookie value
Export again in Netscape cookies.txt format. A raw cookie value, API key, or JSON file will not work.
A song is too long, live, or has an unknown duration
Try a regular video within your server's length limit. Cookies do not remove these music rules.
Direct links work, but searches or playlists still fail
This setting supports individual-video recovery and playback. It does not add cookie authentication to search or playlist discovery.
To check the export format, open the file privately in a text editor. Its first line should be # Netscape HTTP Cookie File or # HTTP Cookie File, with cookie entries below it. See the cookie format requirements.
Cookies cannot resolve every YouTube restriction. Some failures involve host IP restrictions or additional playback requirements; see the yt-dlp YouTube notes. If you need support, share the error message and what you tried, never the cookies file or its contents.
Refresh or remove your cookies
If playback stops working later: repeat step 2 and replace config/youtube-cookies.txt on the host. Keep the same filename and location. DrakoBot reads the file when it retries, so replacing it at the same path does not require a restart.
To stop using cookies: change the existing setting to an empty value and restart the bot:
You can then delete the cookies file from the host.
Last updated