Tremor Watch is a Discord bot that monitors earthquake activity from the Philippine Institute of Volcanology and Seismology (PHIVOLCS) and USGS, delivering real-time earthquake alerts directly to your Discord server.
- ๐ Real-time Earthquake Alerts - Automatically monitors PHIVOLCS/USGS and sends notifications for new earthquakes
- ๐ Multi-Server Support - Configure different alert channels for each Discord server
- ๐ Rich Embeds - Beautiful earthquake information cards with detailed data
- ๐บ๏ธ Interactive Maps - Visual earthquake location using Mapbox integration
- โ๏ธ Configurable Polling - Customize earthquake check intervals via environment variables
- ๐พ Persistent Storage - JSON database tracks sent earthquakes to avoid duplicates
- ๐ Permission Checks - Admin/moderator permissions required for configuration commands
- โฑ๏ธ Rate Limiting - Prevents command spam with smart cooldowns
- ๐ฆ Automatic Backups - Daily database backups with retention management
- โ Input Validation - Comprehensive validation for channels and permissions
- ๐ณ Docker Support - Optimized Docker configuration with pnpm
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- pnpm (v10.19.0 or higher)
git clone https://github.com/yourusername/tremor-watch.git
cd tremor-watchpnpm installCopy the example environment file and configure it:
cp .env.example .envThen edit .env with your values:
# Required Variables
DISCORD_BOT_TOKEN=your_discord_bot_token_here
CLIENT_ID=your_discord_client_id_here
GROQ_API_KEY=your_groq_api_key_here
# Optional Variables
MAPBOX_API_KEY=your_mapbox_api_key_here # For enhanced maps (optional)
GUILD_ID=your_guild_id_here # For testing (optional)
CHANNEL_ID=your_channel_id_here # Default alert channel (optional)
DB_PATH=./data/db.json # Custom database path (optional)
POLLING_INTERVAL_MINUTES=5 # Check interval in minutes (default: 5)
BACKUP_DIR=./data/backups # Backup directory (optional)-
DISCORD_BOT_TOKEN & CLIENT_ID:
- Go to Discord Developer Portal
- Create a new application
- Navigate to the "Bot" section to get your token
- The CLIENT_ID is found in the "General Information" section
-
MAPBOX_API_KEY:
- Sign up at Mapbox
- Navigate to your account page to get your access token
-
GROQ_API_KEY:
- Sign up at Groq
- Generate an API key from your dashboard
# Build TypeScript
pnpm build
# Start the bot
pnpm start
# Or run in development mode (no build required)
pnpm devOnce the bot is running in your server, you can use the following slash commands:
| Command | Description | Cooldown |
|---|---|---|
/help |
Display all available commands | None |
/get-local-quake |
Get information about recent local (Philippine) earthquakes | 30s |
/get-global-quake |
Get information about recent global earthquakes | 30s |
/request-update |
Manually check for new earthquake updates | 60s |
/is-linked |
Check if this server has an earthquake alert channel configured | None |
/poke |
Interact with RanQuake AI assistant | None |
| Command | Description |
|---|---|
/set-earthquake-channel [channel_id] |
Set the channel for earthquake alerts (defaults to current channel) |
/unlink |
Remove the earthquake alert channel for this server |
| Command | Description |
|---|---|
pnpm run backup:create |
Create a manual database backup |
pnpm run backup:list |
List all available backups |
pnpm run backup:clean |
Clean old backups (keep 10 most recent) |
tremor-watch/
โโโ src/ # TypeScript source files
โ โโโ commands/ # Discord bot command definitions
โ โ โโโ utility/ # Utility commands (help, set-channel, etc.)
โ โโโ scripts/ # Core functionality scripts
โ โ โโโ db.ts # JSON database management
โ โ โโโ backupDb.ts # Database backup utility
โ โ โโโ phivolcs.ts # PHIVOLCS data scraping
โ โ โโโ quakeEmbed.ts # Discord embed creation
โ โ โโโ validation.ts # Input validation and permissions
โ โ โโโ rateLimit.ts # Rate limiting utility
โ โ โโโ validateEnv.ts # Environment variable validation
โ โโโ types/ # TypeScript type definitions
โ โ โโโ index.ts # Shared types and interfaces
โ โโโ index.ts # Main bot entry point
โโโ dist/ # Compiled JavaScript (generated)
โโโ docs/ # Documentation
โ โโโ SECURITY.md # Security guidelines
โ โโโ BACKUP.md # Backup documentation
โ โโโ VALIDATION.md # Validation documentation
โ โโโ DOCKER.md # Docker guide
โโโ package.json # Project dependencies
โโโ tsconfig.json # TypeScript configuration
โโโ Dockerfile # Docker configuration
โโโ .env.example # Environment variables template
โโโ .env # Environment variables (create this)
The project includes an optimized Dockerfile using pnpm:
# Build the image
docker build -t tremor-watch .
# Run with environment file
docker run -d \
--name tremor-watch \
--env-file .env \
-v $(pwd)/data:/app/data \
tremor-watchFor more details, see DOCKER.md.
Note: You may need to update the Dockerfile to build TypeScript first:
RUN pnpm build CMD ["node", "dist/index.js"]
- Polling: The bot checks PHIVOLCS/USGS at configurable intervals (default: 5 minutes) for new earthquake data
- Tracking: Each earthquake is tracked in a local JSON database to prevent duplicate alerts
- Validation: User permissions and channel configurations are validated before processing
- Alerting: When a new earthquake is detected, the bot sends a rich embed to all configured server channels
- Rate Limiting: Commands have cooldowns to prevent spam and API abuse
- Backups: Database is automatically backed up daily with retention management
- Persistence: Server channel configurations are stored in the database and persist across bot restarts
- Security Guidelines - Environment variable management and secret rotation
- Backup Guide - Database backup and restore procedures
- Validation Guide - Input validation and permission checks
- Docker Guide - Docker deployment and configuration
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the ISC License.
- PHIVOLCS - Philippine Institute of Volcanology and Seismology
- USGS - United States Geological Survey
- Discord.js - Powerful library for interacting with the Discord API
If you encounter any issues or have questions, please open an issue on GitHub.
Made with โค๏ธ for earthquake awareness and safety