Discord Bot2023

YouTube Discord Bot

Discord Bot that automatically crawls the latest videos and live streams from YouTube channels and pushes them to specified channels.

YouTube Discord Bot

Project Overview

An automated Discord bot dedicated to crawling the latest videos and live content from YouTube channels and pushing them to specified Discord channels. Supports automated scheduling (checks every hour/half-hour) and manual triggers, with complete channel management to avoid duplicate pushes.

Technical Challenges & Solutions

YouTube Crawler Implementation

Needed to stably crawl YouTube channel content and handle anti-crawling mechanisms.

Solution:
Implemented a dual crawler strategy: Fetch API as the primary method, and Puppeteer as a backup to ensure stability.

Duplicate Content Avoidance

Tracking pushed videos to avoid notifying users repeatedly.

Solution:
Established a local cache mechanism to record pushed content IDs and implemented smart filtering algorithms.

Scheduled Task Management

Ensuring the bot executes scheduled checks regardless of service restarts.

Solution:
Used PM2 for process management with automatic restart and error handling configuration.

Architecture

系統架構圖

Developed with Node.js + Discord.js, supporting both Fetch API and Puppeteer crawling modes. Managed by PM2 for stability and scheduled tasks.

Learnings

I deeply learned Discord bot development, web crawling techniques, and automated task design. Gained valuable experience in handling anti-crawling mechanisms and ensuring service stability.

Tech Stack

Core Tech

Node.jsDiscord.jsJavaScript

Crawler Tech

PuppeteerYouTube API

Deployment Management

PM2