A Discord bot for portfolio and transaction notifications.
- Sends direct messages (DM) about new transactions every hour
- Supports commands:
!ping- Check if the bot is online!hello- Get a DM reply from the bot!alert- Test DM sending!lasttransactions- Get your last 24h transactions!help- List available commands
- Node.js 18+
- A Discord bot token
- A running backend API reachable at
API_BASE_URL(defaulthttp://127.0.0.1:5001)
In your bot application settings:
- Enable
MESSAGE CONTENT INTENTunder Privileged Gateway Intents - Ensure the bot is invited to your server with permissions to read/send messages
-
Clone the repository
git clone <your-repo-url> cd discord-bot
-
Install dependencies
npm install
-
Configure environment variables
Create a
.envfile at the project root:DISCORD_TOKEN=your_discord_bot_token_here API_BASE_URL=http://127.0.0.1:5001
-
Start the bot
npm start
-
Verify backend connectivity
curl -X POST http://127.0.0.1:5001/get_discord_users_portfolios
A successful response confirms the bot can reach the backend.
- Add Discord user IDs to
usersToNotifyinindex.jsas strings - Backend integration is implemented in
master.js
master.js expects these POST endpoints on API_BASE_URL:
/get_discord_user_portfolios/get_discord_users_portfolios/get_deals/get_deals_valuation/get_last_transactions/get_deals_total_volume/get_deals_total_amount/get_deals_total_sold_amount
Expected payload naming is currently mixed and should be preserved unless both sides are updated together:
- Discord ID field:
discord_id - Portfolio arrays may appear as
portfolioorPortfolios
index.js- Main bot logic and command handlingcheckTransactions.js- Periodic transaction checking and DM notificationsmaster.js- API calls for user portfolios and transactions.env- Environment variables (not tracked by git).gitignore- Files and folders excluded from git
- Never share your
.envfile or bot token .envis excluded from git by default
- Backend unreachable on startup:
- The bot now checks backend availability at startup.
- If unavailable, it logs errors and retries every 60 seconds.
- Check backend from Discord:
- Use
!backendin a server channel to see current backend reachability.
- Use
- DM alert command fails:
- Make sure the user allows DMs from server members.
MIT