by Lazy Sloth
Discord Youtube Channel Video Lister Bot
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):
Created: | Last Updated:
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!