Discord Youtube Channel Video Lister Bot

Test this app for free
107
import os
import csv
import re
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
import time
from discord.ext import commands
import discord

# Get the Discord bot token from the environment variables
discord_bot_token = os.environ['DISCORD_BOT_TOKEN']

# Create the bot with all intents
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents)

# Set the default maximum number of videos to be listed
max_videos = 10

@bot.command()
async def set_max_videos(ctx, number):
Get full code

Created: | Last Updated:

This app uses Selenium to navigate directly to the "Videos" tab of a specified YouTube channel URL, scrolls down until there are no new videos or the maximum number of videos to be listed is reached, retrieves the list of videos on the channel, and shares the video data in the same Discord thread it was mentioned to scrape it. The app also handles errors during the extraction of videos and prints the progress of the number of videos data that is being collected throughout the app lifecycle. The app requires the environment variable DISCORD_BOT_TOKEN to be set to the token of the Discord bot. The maximum number of videos to be listed can be set using the command "!set_max_videos <number>" with the same bot. The bot is created with all intents to make it work properly. The app also validates the YouTube channel URL provided by the user. The command to list the videos is "!list_videos <youtube_channel_videos_url>".

Introduction to the Discord YouTube Channel Video Lister Bot Template

Welcome to the Discord YouTube Channel Video Lister Bot template! This template is designed to help you create a Discord bot that uses Selenium to scrape and list videos from a specified YouTube channel's "Videos" tab. The bot will be able to set a maximum number of videos to list and share the video data directly in a Discord thread. This guide will walk you through the steps to set up and deploy your bot using the Lazy platform.

Clicking Start with this Template

To begin using this template, click on the "Start with this Template" button. This will initialize the template in the Lazy Builder interface, pre-populating the code for you.

Initial Setup

Before you can use the bot, you need to set up an environment secret for the Discord bot token. Follow these steps to acquire the token:

  • Go to the Discord Developer Portal (https://discord.com/developers/applications).
  • Create a new application and give it a name.
  • Under the "Bot" tab, click "Add Bot" and confirm the creation.
  • Copy the token provided under the "TOKEN" section.

Once you have your Discord bot token, add it as an environment secret in the Lazy Builder:

  • Navigate to the Environment Secrets tab within the Lazy Builder.
  • Create a new secret with the key DISCORD_BOT_TOKEN and paste the token you copied as the value.

Test: Pressing the Test Button

After setting up the environment secret, press the "Test" button to begin the deployment of your app. The Lazy CLI will handle the deployment process for you.

Entering Input

There is no need for additional user input through the CLI for this template, as the commands to interact with the bot will be entered directly within Discord once the bot is running.

Using the App

Once the bot is deployed, you can invite it to your Discord server and start using it with the following commands:

  • !set_max_videos <number> - Sets the maximum number of videos to list.
  • !list_videos <youtube_channel_videos_url> - Lists videos from the specified YouTube channel URL.

Integrating the App

To integrate the bot into your Discord server, follow these steps:

  • In the Discord Developer Portal, navigate to your application's "OAuth2" tab.
  • Under "SCOPES," select "bot" and choose the appropriate permissions for your bot.
  • Use the generated URL to invite the bot to your Discord server.

Once the bot is in your server, you can use the commands listed above to interact with it.

Remember, the Lazy platform handles all the deployment details, so you don't need to worry about setting up Selenium or any other libraries on your local machine. Enjoy your new Discord bot, and happy coding!

Technologies

Enhance Selenium Automation with Lazy AI: API Testing, Scraping and More Enhance Selenium Automation with Lazy AI: API Testing, Scraping and More
YouTube YouTube
Discord Automation & Bots Discord Automation & Bots

Similar templates

We found some blogs you might like...