An automated solution for TCGplayer sellers to receive real-time Discord notifications for new orders, including buyer information and automated order tracking.
Standard TCGplayer email notifications omit the buyer's name. This project automates the process of watching for new order emails via the Gmail API, scraping the buyer's name from the seller portal using Playwright, persisting data in a local SQLite database to track the fulfillment lifecycle, and pushing a formatted alert to a Discord channel with built-in status tracking.
- Uses the Gmail API to poll for unread TCGplayer order confirmations every 10 minutes.
- Leverages Playwright (Chromium) to securely retrieve buyer names and item details from the TCGplayer Seller Portal.
- Stores order history, buyer names, and fulfillment status in a local SQLite database.
- Sends embeds to Discord, with the buyer's name featured in the header for quick identification.
- Supports Discord reactions to update order status in real-time.
- Architected to run on a zero-cost Google Cloud Platform (GCP) e2-micro instance using a Linux Swap file for memory management.
- Language: Python 3.x
- Database: SQLite3
- Browser Automation: Playwright (Chromium)
- Cloud Infrastructure: Google Cloud Platform (Compute Engine), Docker
- APIs: Gmail API (OAuth 2.0), Discord API (discord.py)
!sync: Manually triggers a Gmail check and processes new orders immediately.!pending: Displays a list of all orders currently marked as "Pending" in the database.!recent [x]: Shows the lastxorders processed by the bot.!remove [OrderID]: Manually deletes a specific order entry from the database.
- Enable the Gmail API in GCP, download credentials.json, and run get_token.py to generate token.json.
- Run auth_tcgplayer.py, then log into your Seller Portal manually. Press Enter in the terminal to save your session to tcg_state.json.
- Create a .env file with your DISCORD_BOT_TOKEN, DISCORD_CHANNEL_ID, and DISCORD_ROLE_ID.
To run on a free-tier e2-micro instance, a swap file may be needed to prevent Playwright from crashing on low-RAM hardware:
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstabBuild and run the container.
docker build -t tcg-bot .
docker run -d \
--name tcg-order-notifier \
-v $(pwd)/orders.db:/app/orders.db \
--restart unless-stopped \
tcg-bot