This bot automatically checks specified YouTube channels for new videos and posts the video URLs to a Discord channel using a webhook.
- Monitors multiple YouTube channels for new uploads
- Sends new video URLs to a Discord channel via webhook
- Runs automatically every hour using GitHub Actions
- Avoids duplicate postings by tracking recent video IDs
The script will fail without proper permissions set for GitHub Actions.
To set the correct permissions:
- Go to your GitHub repository's settings.
- Click on "Actions" in the left sidebar.
- Scroll down to the "Workflow permissions" section.
- Select "Read and write permissions".
- Save the changes.
These permissions are necessary for the GitHub Action to update the posted_videos.json
file in your repository.
-
Fork this repository to your GitHub account.
-
Clone your forked repository to your local machine:
git clone https://github.com/your-username/youtube-discord-bot.git cd youtube-discord-bot
-
Edit the
channels.json
file to include the YouTube channel IDs you want to monitor. Each ID should be in quotes and separated by commas:[ "UC-lHJZR3Gqxm24_Vd_AJ5Yw", "UCq-Fj5jknLsUf-MWSy4_brA", "UCX6OQ3DkcsbYNE6H8uQQuVA" ]
-
Create a Discord webhook:
- In your Discord server, go to Server Settings > Integrations > Webhooks
- Click "New Webhook", customize it if desired, and copy the webhook URL
-
Add the Discord webhook URL as a secret in your GitHub repository:
- Go to your repository on GitHub
- Click on Settings > Secrets > Actions
- Click "New repository secret"
- Name:
DISCORD_WEBHOOK_URL
- Value: Your Discord webhook URL
- Click "Add secret"
-
Commit and push your changes:
git add channels.json git commit -m "Update monitored YouTube channels" git push
-
Set the correct GitHub Actions permissions as described in the "Important" section above.
-
The GitHub Action should now be set up and will run automatically every hour. You can also manually trigger it from the Actions tab in your GitHub repository.
- The bot checks the specified YouTube channels every hour for new videos.
- When a new video (less than 24 hours old) is found, it posts the video URL to the Discord channel using the webhook.
- The bot keeps track of posted videos to avoid reposting the same videos.
If you encounter any issues:
- Check the GitHub Actions logs for any error messages.
- Ensure your
DISCORD_WEBHOOK_URL
secret is set correctly. - Verify that the YouTube channel IDs in
channels.json
are correct. - Double-check that you've set the correct permissions for GitHub Actions as described in the "Important" section.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.