A Python application that monitors Reddit subreddits for new posts and comments, automatically forwarding them to Discord via webhooks.
- Monitor multiple subreddits simultaneously
- Each subreddit posts to its own Discord channel
- Keyword monitoring - Search for specific keywords in posts and comments
- Separate webhooks for regular posts and keyword matches
- Posts updates to Discord with rich formatting
- Includes post metadata (author, score, comments, flair)
- Tracks state independently for each subreddit
- Handles NSFW and spoiler warnings
- Runs continuously with configurable check intervals
- Easy enable/disable individual subreddits or features
- Python 3.7 or higher
- A Reddit account to create an app
- A Discord server with webhook access
pip install -r requirements.txt- Go to reddit.com/prefs/apps
- Scroll to the bottom and click "create another app..."
- Fill in the form:
- name: Choose any name (e.g., "Discord Monitor")
- App type: Select "script"
- description: Optional
- about url: Optional
- redirect uri: Enter
http://localhost:8080(required but not used)
- Click "create app"
- Note down:
- client_id: The string under "personal use script" (14 characters)
- client_secret: The "secret" value shown
For each subreddit you want to monitor, create a webhook:
- In your Discord server, go to Server Settings → Integrations
- Click "Webhooks" → "New Webhook"
- Give it a descriptive name (e.g., "r/python Monitor")
- Choose which channel should receive posts from this subreddit
- Click "Copy Webhook URL"
- Repeat for each subreddit you want to monitor
-
Copy the example environment file:
cp .env.example .env
-
Edit
.envand add your Reddit credentials:REDDIT_CLIENT_ID=your-14-char-client-id REDDIT_CLIENT_SECRET=your-client-secret REDDIT_USER_AGENT=Discord Monitor Bot (by /u/YourUsername) CHECK_INTERVAL=300Note: Replace
YourUsernamein the user agent with your actual Reddit username.
Edit subreddits.json to define which subreddits to monitor and where to post them:
[
{
"subreddit": "python",
"webhook_url": "https://discord.com/api/webhooks/your-webhook-for-python",
"enabled": true,
"monitor_posts": true,
"monitor_keywords": false,
"keyword_webhook_url": ""
},
{
"subreddit": "LocalLLaMA",
"webhook_url": "https://discord.com/api/webhooks/your-webhook-for-localllama",
"enabled": true,
"monitor_posts": true,
"monitor_keywords": true,
"keyword_webhook_url": "https://discord.com/api/webhooks/your-webhook-for-keywords"
}
]Configuration options:
subreddit: Subreddit name (without "r/" prefix) (required)webhook_url: Discord webhook URL for regular posts (required)enabled: Set tofalseto temporarily disable all monitoring (default:true)monitor_posts: Set tofalseto disable regular post monitoring (default:true)monitor_keywords: Enable keyword monitoring for this subreddit (default:false)keyword_webhook_url: Separate webhook for keyword matches (optional, useswebhook_urlif empty)
If you want to monitor for specific keywords, edit keywords.json:
{
"keywords": [
"antgear",
"antgear.com",
"ant gear"
],
"case_sensitive": false,
"search_posts": true,
"search_comments": true
}Keyword options:
keywords: Array of keywords/phrases to search forcase_sensitive: Whether matching should be case-sensitive (default:false)search_posts: Search in post titles and bodies (default:true)search_comments: Search in comments (default:true)
How it works:
- Keywords use word-boundary matching (won't match "antgear" in "merchantgear")
- Posts and comments that contain ANY of the keywords will be posted to the keyword webhook
- Each match shows which keywords were found and where (title/body/comment)
python main.pyThe script will:
- Check all enabled subreddits every 5 minutes (configurable)
- Post new Reddit posts to their respective Discord channels
- Track state independently for each subreddit
- Continue running until you stop it with Ctrl+C
On the first run, the monitor will check recent posts from each subreddit. After that, it only posts content that appears after the last check for each subreddit.
To add a new subreddit:
- Create a Discord webhook for the new channel
- Add an entry to
subreddits.json - Restart the monitor
To temporarily disable a subreddit:
- Set
"enabled": falseinsubreddits.json - Restart the monitor
To reset state for a specific subreddit:
# Edit last_check.json and remove the subreddit entryTo reset all state:
rm last_check.jsonREDDIT_CLIENT_ID: Your Reddit app client ID (required)REDDIT_CLIENT_SECRET: Your Reddit app client secret (required)REDDIT_USER_AGENT: User agent string (required)CHECK_INTERVAL: How often to check for new posts (in seconds, default: 300)
Each subreddit entry supports:
subreddit: Name of the subreddit (required)webhook_url: Discord webhook URL for regular posts (required)enabled: Whether to monitor this subreddit (default: true)monitor_posts: Monitor regular posts (default: true)monitor_keywords: Monitor for keywords (default: false)keyword_webhook_url: Webhook for keyword matches (optional)
Global keyword monitoring settings:
keywords: List of keywords/phrases to search forcase_sensitive: Case-sensitive matching (default: false)search_posts: Search in posts (default: true)search_comments: Search in comments (default: true)
.
├── main.py # Main script
├── reddit_monitor.py # Reddit API integration (posts & comments)
├── discord_poster.py # Discord webhook integration
├── keyword_matcher.py # Keyword filtering and matching
├── state_manager.py # State persistence (per-subreddit)
├── requirements.txt # Python dependencies
├── .env # Reddit API credentials (create from .env.example)
├── .env.example # Configuration template
├── subreddits.json # Subreddit-to-webhook mappings
├── keywords.json # Keyword monitoring configuration
├── last_check.json # State file (auto-generated, per-subreddit)
└── README.md # This file
Make sure you've created a .env file and added your Reddit app credentials.
- Verify your client_id and client_secret are correct
- Check that your user agent is properly formatted
- Ensure the subreddit name is correct (without "r/" prefix)
- Check that the Discord webhook URL is correct
- Verify the webhook hasn't been deleted in Discord
If you encounter rate limiting errors, increase the CHECK_INTERVAL value in your .env file to check less frequently.
# Using screen
screen -S subwatch
python main.py
# Press Ctrl+A then D to detach
# Reattach later
screen -r subwatchCreate /etc/systemd/system/subwatch.service:
[Unit]
Description=SubWatch - Reddit to Discord Monitor
After=network.target
[Service]
Type=simple
User=your-username
WorkingDirectory=/path/to/subwatch
ExecStart=/usr/bin/python3 main.py
Restart=always
[Install]
WantedBy=multi-user.targetThen:
sudo systemctl enable subwatch
sudo systemctl start subwatch
sudo systemctl status subwatchSubWatch is released under the MIT License. You are free to use, modify, and distribute this software for any purpose, including commercial use.