How Do I Add a YouTube Bot to My Discord Server?


Angela Bailey

If you’re a Discord server owner and want to enhance the experience for your members, adding a YouTube bot can be a great way to do it. With a YouTube bot, you can automatically post updates about new videos from your favorite channels, play music from YouTube, and even get live notifications when a streamer goes live. In this tutorial, we’ll walk you through the steps to add a YouTube bot to your Discord server.

Step 1: Creating a Discord Bot

Before we can add a YouTube bot to our server, we need to create a Discord bot first. To do this:

  1. Open the Discord Developer Portal: Go to the Discord Developer Portal and log in with your Discord account.
  2. Create a New Application: Click on the “New Application” button and give it a name.
  3. Create a Bot: In the left sidebar, click on “Bot” and then click on “Add Bot”. Confirm when prompted.
  4. Copy Token: Under the bot section, click on “Copy” next to the token. This token will be used later to authenticate our bot.

Step 2: Inviting the Bot to Your Server

To add the bot to your server:

  1. Create an OAuth2 URL: In the left sidebar of the developer portal, click on “OAuth2”. In the “Scopes” section, select “bot”.

    Then, in the “Bot Permissions” section, select permissions like “Send Messages”, “Manage Messages”, and others based on your requirements. Copy the generated URL.

  2. Authorize the Bot: Open the generated URL in your browser and select your server from the dropdown list. Authorize the bot to join your server.

Step 3: Adding the YouTube Bot Code

Now that we have a bot and it’s in our server, let’s add the code to make it work with YouTube. For this tutorial, we’ll be using a popular Discord.js library. Make sure you have Node.js installed on your system before proceeding:

  1. Create a New Project Folder: Create a new folder on your computer where you want to store the bot files.
  2. Open Terminal or Command Prompt: Navigate to the project folder using Terminal (Mac/Linux) or Command Prompt (Windows).
  3. Initialize Node.js Project: Run the command npm init -y to initialize a new Node.js project with default settings.
  4. Install Discord.js Library: Run the command npm install discord.js.

Step 4: Writing Your Bot Code

In your project folder, create a new file called “bot.js”. Open it in a text editor and add the following code:

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
    console.log(`Logged in as ${client.user.tag}!`);

client.on('message', msg => {
    if (msg.content === '!ping') {


Replace ‘YOUR_DISCORD_BOT_TOKEN’ with the token you copied in Step 1.

Step 5: Running Your Bot

In your terminal or command prompt, run the following command:

node bot.js

If everything is set up correctly, you should see “Logged in as YOUR_BOT_NAME!” in the console. Your bot is now online and ready to use!


You have successfully added a YouTube bot to your Discord server. Now you can customize it further by adding YouTube API integration to fetch videos or music from specific channels. Explore the Discord.js documentation for more possibilities and have fun enhancing your server’s experience!

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy