Skip to content

feat: Add Discord Bot for Activity Tracking#84

Merged
joelamouche merged 2 commits intoTheSoftwareDevGuild:mainfrom
PeterOche:discord-bot
Oct 2, 2025
Merged

feat: Add Discord Bot for Activity Tracking#84
joelamouche merged 2 commits intoTheSoftwareDevGuild:mainfrom
PeterOche:discord-bot

Conversation

@PeterOche
Copy link

feat: Add Discord Bot for Activity Tracking

Closes: #77

This pull request introduces a new discord-bot service to track user activity within the Discord server. The bot listens for user messages and records corresponding "activity events" into the PostgreSQL database, laying the foundation for a future points and rewards system.

Key Features Implemented:

  • New discord-bot Service: A standalone TypeScript service built with Node.js and the discord.js library.
  • Message Tracking: Listens to messageCreate events and records them as activity points.
  • Database Integration: Adds a new activity_events table to the existing PostgreSQL database. A migration script is included.
  • Rate Limiting: Implements a simple in-memory rate limiter to prevent spam (default: 10 messages/user/minute).
  • Configuration: Fully configurable via a .env file, with schema validation using Zod.
  • Docker Integration: The new service is integrated into the existing docker-compose.yml for easy setup and deployment.
  • Robustness: Includes structured logging with Pino, graceful shutdown handling, and comprehensive error management.

How to Test:

  1. Create .env file: In the discord-bot directory, copy env.example to .env and fill in your Discord Bot Token, App ID, and Server (Guild) ID.
  2. Enable Gateway Intent: In the Discord Developer Portal for your bot, navigate to the "Bot" tab and enable the "Message Content Intent" under "Privileged Gateway Intents".
  3. Start Database:
    docker-compose up postgres -d
  4. Run Migration:
    psql postgresql://guild_user:guild_password@localhost:5433/guild_genesis -f discord-bot/migrations/001_create_activity_events.sql
  5. Start the Bot:
    cd discord-bot
    npm run dev
  6. Invite & Verify: Invite the bot to your Discord server. Send a message in a channel and confirm that the terminal logs an "Activity event created" message.
image

Copy link
Contributor

@joelamouche joelamouche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall great job!

I have a few comments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably "the-guild-discord-bot"

@joelamouche joelamouche linked an issue Oct 1, 2025 that may be closed by this pull request
@PeterOche
Copy link
Author

i have made the changes you requested @joelamouche. Kindly review

Copy link
Contributor

@joelamouche joelamouche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@joelamouche joelamouche enabled auto-merge (rebase) October 2, 2025 11:37
@joelamouche
Copy link
Contributor

Nice work @PeterOche ! Don't hesitate to create a profile on theguild.dev to get badges for this task, or sharing twitter profile if you want some promotion 🚀

@joelamouche joelamouche merged commit 45f8828 into TheSoftwareDevGuild:main Oct 2, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discord Bot foundation

2 participants

Comments