Skip to content

GDGGhardaia47/discord_bot

Repository files navigation

Discord Bot 🤖

A Discord bot built with Python and clean architecture.

Features & Commands

  • Startup Greeting: Automatically says "👋 Hi everyone! I'm online and ready to go!" in the first available text channel of every server it's in when it starts.
  • Message Tracking: Continuously tracks the last message sent by each user and automatically saves this data to a CSV file (statistics/{Server Name}/last_messages.csv).
  • Commands (Prefix: !):
    • !export — Exports all statistics (members, last messages, and server structure) to the statistics/{Server Name}/ directory.
    • !members — Exports a list of all server members, their roles, and account statistics (member join duration, account age, top role, and boost status) to statistics/{Server Name}/members.csv.
    • !serverinfo or !structure — Exports the complete server structure (channels, categories, and roles) to statistics/{Server Name}/server_structure.md.
    • !map — Rebuilds an Obsidian markdown tree of channels and role links in obsidian/{Server Name}/.

Project Structure

discord_bot/
├── main.py                  # Entry point
├── .env                     # Discord token (not committed)
├── .gitignore
├── requirements.txt
├── config/
│   ├── __init__.py
│   └── settings.py          # Environment variable loading & validation
├── domain/
│   ├── __init__.py
│   └── models.py            # Core business models (ChannelInfo, MemberInfo, etc.)
├── application/
│   ├── __init__.py
│   ├── command_handler.py   # Routes messages to appropriate commands
│   ├── event_handlers.py    # Startup event handlers
│   └── statistics_service.py # Gathers server data & exports reports
├── infrastructure/
│   ├── __init__.py
│   └── bot.py               # Discord client setup & wiring
├── obsidian/                # Obsidian markdown map exports
└── statistics/              # Generated reports (CSV/Markdown)
    └── {Server Name}/
        ├── last_messages.csv
        ├── members.csv
        └── server_structure.md

Setup

  1. Install dependencies:

    pip install -r requirements.txt
  2. Add your Discord bot token to the .env file:

    DISCORD_TOKEN=your_actual_token_here
  3. Run the bot:

    python main.py

Architecture Layers

Layer Responsibility
config Load & validate environment variables
domain Core business logic (entities, value objects)
application Use cases, services, and event/command handlers
infrastructure External services (Discord client, APIs…)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages