a simple and powerful discord bot that scans chat messages for YouTube URLs and instantly sends back the corresponding video files.
With its seamless integration, youtube-to-mp4 simplifies the process of sharing YouTube videos within your Discord server. Whether you're discussing music, tutorials, or funny clips, DiscordTube ensures quick access to the content you love, enhancing the overall user experience.
- python
- discord
- yt-dl
- Go to the Discord Developer Portal website and log in with your Discord account.
- Click on the
New Application
button to create a new application for your bot. - Enter a name for your application and click the
Create
button. - In the left sidebar, click on the
Bot
tab. - Click on the
Add Bot
button and confirm the action by clickingYes, do it!
in the dialog that appears.
Your Bot token is essential for your bot to authenticate and connect to Discord servers.
- Under the
Token
section, click on theCopy
button to copy the bot token to your clipboard. - Save your token somewhere safe and don't share it with others
To enable necessary intents for your bot, follow these additional steps:
- Go back to the Discord Developer Portal and click on the
Bot
tab. - Under the
Privileged Gateway Intents
section, enable the intents that your bot requires. Common intents includePresence Intent
andServer Members Intent
. Note that certain intents require verification by Discord.
- In the left sidebar, click on the
OAuth2
tab. - In the
Scopes
section, select thebot
checkbox. This will generate a URL for adding your bot to a server. - Scroll down to the
Bot Permissions
section and select the required permissions that your bot will need. These permissions define what your bot can do on Discord servers. - Copy the generated URL from the
Scopes
section. - Open a new browser tab and paste the URL into the address bar. This will allow you to add the bot to a server of your choice. Select a server and authorize the bot.
- Open a Terminal and navigate to the directory where you want to clone your bot's repository.
- Clone the repository by running the command
git clone https://github.com/wiiiviii/youtube-to-mp4.git
. - Navigate into the cloned repository by running the command
cd youtube-to-mp4
. - Install the required dependencies by running the command
pip install -r requirements.txt
. - Add your token and desired prefix to the
config.py
file. - Run your bot by executing the appropriate command, such as
python bot.py
orpython3 bot.py
.
When the bot is active on your Discord server, simply post a message containing a YouTube video link.
- the bot will
automatically detect youtube urls
and initiate the process. - the bot will
retrieve the video file and convert
it if necessary. - the bot will
send the video back to you as a file
in the same chat channel
[prefix]check
: checks if the bot is responding
[prefix]shutdown
: initiate bot shutdown process
To set up auto-restart for your bot using PM2, follow these steps:
- Run the command
npm install pm2 -g
to install PM2 globally on your system. - Use
cd /path/to/your/bot
to navigate to the directory where you placed the bot - Run the command
pm2 start bot.py --name examplename
,- replacing
examplename
with the desired name for your PM2 process. - example:
pm2 start bot.py --name coolbot
- replacing
- To verify that it started properly you can run the command
pm2 list
. this will return a list of all running PM2 processes and you can look for your bot's process with the specified name in the output. - Use various PM2 commands to manage your bot process:
- To stop the process:
pm2 stop <name>
(e.g.,pm2 stop mybot
) - To start the process:
pm2 start <name>
(e.g.,pm2 start mybot
) - To restart the process:
pm2 restart <name>
(e.g.,pm2 restart mybot
) - To view logs:
pm2 logs <name>
(e.g.,pm2 logs mybot
) - For more advanced usage, refer to the PM2 documentation.
- To stop the process:
- Run the command
pm2 startup
to generate a command that enables PM2 to start automatically on system boot. - Follow the instructions provided by the command to complete the setup.