Discord bot that tracks cryptocurrency and asset prices using Pyth Network and posts updates to Discord channels.
Pyth Network
|
Price Service
|
shared/prices.json
|
+----------------+----------------+
| | |
Bot BTC Bot ETH Bot SOL
(token) (token) (token)
| | |
+----+----+ +----+----+ +----+----+
| | | | | |
Discord SQLite Discord SQLite Discord SQLite
- Price Service fetches prices from Pyth Network every 30 seconds
- Prices are written to shared JSON file and SQLite database
- Each bot instance reads prices and updates its Discord nickname
- Multiple bot instances run in parallel, one per token
Each bot is independent - add more by adding tokens to .env.
- Docker and Docker Compose
- A Discord application with bot tokens
-
Copy the example environment file:
cp .env.example .env -
Edit
.envand add your Discord bot tokens. Get tokens from https://discord.com/developers/applications -
In the Discord developer portal for each bot:
- Enable "Public Bot"
- Enable "Server Members Intent"
- Enable "Message Content Intent"
-
Invite each bot to your server using the OAuth2 URL in the Discord developer portal
-
The CRYPTO_FEEDS variable controls which assets to track:
CRYPTO_FEEDS=BTC:feed_id,ETH:feed_id,...Get feed IDs from https://insights.pyth.network/price-feeds?search=btc
docker-compose up -d --build
docker-compose ps
docker-compose logs -f
docker-compose down
!status
The health endpoint is available at localhost:8080/health
curl http://localhost:8080/health
Edit .env and change UPDATE_INTERVAL_SECONDS (default 12 seconds):
UPDATE_INTERVAL_SECONDS=30
- Add a new bot token in
.env:DISCORD_TOKEN_ASSETNAME=your_token - Add the Pyth Network feed ID in
CRYPTO_FEEDS:ASSETNAME:feed_id - Rebuild:
docker-compose up -d --build
Simply add more tokens to .env:
DISCORD_TOKEN_BTC=your_btc_token
DISCORD_TOKEN_ETH=your_eth_token
DISCORD_TOKEN_NEWTICKER=your_new_token
The bot will automatically spawn new instances for each token.
!BTC- Get BTC price!ETH- Get ETH price/price- Slash command for prices!silverchart- Get silver price chart!status- Check system status (BTC bot only)
- Docker with Docker Compose
- Debian (Docker base image)
- Rust (edition 2021)
- Serenity (Discord bot library)
- SQLite (database)
- Pyth Network (price feeds)
- Axum (HTTP server)
- Plotters (chart generation)