This bot lets you log your expenses by DMing it on Discord, and it will append each entry into a Google Sheet with the message, timestamp, and sender name.
- Logs DMs like
Coffee - $3to Google Sheets - Timestamps each entry
- Requires no external commands or prefixes
- Easy to deploy locally
git clone https://github.com/your-username/expense-bot.git
cd expense-botnpm installCreate a .env file in the root folder:
DISCORD_TOKEN=your_discord_bot_token_here
SHEET_ID=your_google_sheet_id_here
How to get SHEET_ID:
Open your Google Sheet and copy the string between /d/ and /edit:
https://docs.google.com/spreadsheets/d/1abcDEF1234567XYZ/edit#gid=0
^^^^^^^^^^^^^^^^^^^^^
- Go to Discord Developer Portal
- Click New Application โ Name it โ Create
- Go to Bot tab โ Click Add Bot
- Toggle MESSAGE CONTENT INTENT on
- Copy the token and put it in
.envasDISCORD_TOKEN
If you want to test it in servers too:
- Go to OAuth2 > URL Generator
- Scopes:
bot - Bot permissions:
Send Messages,Read Messages,Message Content - Copy the generated URL and open it in a browser to invite the bot
- Go to Google Sheets
- Create a new sheet (name it
Sheet1, or update the code to match your name) - Add this header in Row 1:
Timestamp | Message | Username
- Go to Google Cloud Console
- Create a new project
- Go to APIs & Services > Library
- Enable Google Sheets API
- Enable Google Drive API
- Go to APIs & Services > Credentials
- Click Create Credentials > Service Account
- After creation, go to the service account and click Keys > Add Key > JSON
- Save the downloaded file as
credentials.jsonin your project root
- Open
credentials.json - Copy the value of
"client_email" - Share your Google Sheet with that email (
Editoraccess)
node index.jsThen open Discord and DM your bot:
Snacks - $5
You should see the entry appear in your Google Sheet.
expense-bot/
โ
โโโ credentials.json # Google service account key
โโโ .env # Secrets (token, sheet ID)
โโโ index.js # Main bot logic
โโโ package.json
โโโ README.md
Make sure to add this to your .gitignore:
.env
credentials.json
node_modules/
| Timestamp | Message | Username |
|---|---|---|
| 2025-04-29 15:05:00 | Coffee - $3 | rajvardhansinghdodiya |
| 2025-04-29 15:10:00 | Snacks - $5 | rajvardhansinghdodiya |
Made with โ and ๐ by [Your Name]
Feel free to fork and extend this project!