A simple metronome app that runs inside Discord Voice Channels as an embedded Activity, using a Bun backend and SQLite for storing user BPM preferences.
Works only inside Discord as an Activity
- Runs natively inside Discord via the Embedded App SDK
- Authenticates Discord users securely via OAuth2
- Saves/loads BPM settings from SQLite
- Audio click metronome with easily adjustable tempo
- Works securely over HTTPS
- Serves compliant Terms of Service and Privacy Policy pages at
/termsand/privacy
- Bun
- SQLite
- Discord Developer account with an Application created
- Node.js (optional)
- Linux (Ubuntu/RedHat or similar) server
- Nginx or Cloudflare Tunnel (cloudflared)
- Domain name with DNS configured and HTTPS
Clone the repository or download the source code:
git clone https://github.com/IvanDeus/DiscordActivity-Metronome-ts.git
cd DiscordActivity-Metronome-ts
Install Bun. No external npm packages are needed as the project uses Bun's built-in APIs (bun:sqlite and Bun.serve).
If you wish to run the app in production using PM2, you will also need pm2 installed via Node.js:
npm install -g pm2- Go to the Discord Developer Portal and create a new application.
- Under the OAuth2 tab, save your Client ID and Client Secret, and add a redirect URI (base URL to the public HTTPS URL where your app is hosted).
- Navigate to the URL Mapping section (or Activities settings) and set the same public HTTPS URL as on previous step.
- In Supported Platforms section Allow iOS, Android and Web.
- In General Information, fill in the Terms of Service URL (e.g.,
https://<yourdomain>/terms) and Privacy Policy URL (e.g.,https://<yourdomain>/privacy) to comply with Discord's developer policies.
Copy dotenv-example to .env:
cp dotenv-example .env
Edit .env and add your actual data: DISCORD_CLIENT_ID and DISCORD_CLIENT_SECRET.
Build Frontend:
cd metronome-frontend
bun install
bun run build
cd ..
For development/testing, you can run the app directly using Bun:
bun run index.tsTo run the App in production in the background using PM2, run:
pm2 start index.ts --name "discord-metronome" --interpreter bunThis step will also automatically initialize the SQLite database (metronome.db) if it doesn't exist.
To view logs, run pm2 logs discord-metronome. To stop it, run pm2 stop discord-metronome.
To test the app inside Discord, your application needs to be served over HTTPS. You can use Cloudflare Tunnels (recommended for quick testing):
cloudflared tunnel --url http://localhost:3000Then paste the generated https:// URL into the Discord Developer Portal URL mappings.
Alternatively, use Nginx for a production server:
server {
listen 443 ssl;
server_name yourdomain.com;
ssl_certificate /path/to/fullchain.cer;
ssl_certificate_key /path/to/privkey.key;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}Hop into a Discord Voice Channel, launch your Activity, and start the metronome!
2026 [ ivan deus ]