How djthegr8/rolex works
Project type and purpose
• Rolex/Hermes is a .NET Core 3.1 Discord bot. It’s a backend “service” that connects to Discord via the Discord API, listens for commands, routes them to one of many modular command handlers, and optionally persists or caches data in SQLite or Redis.
File structure
• Top level:
• Dockerfile, VS solution (.sln), scripts for pull & restart
• Hermes/Program.cs & Hermes.csproj – entry point & project definition
• Hermes/Modules – command handlers, organized by feature area (General, Moderation, Developer, etc.)
• Hermes/Modules/Services – core abstractions (ICommands, InteractionHandler, SQLite, RedisClass, etc.)
• Hermes/Utilities – supporting classes (Collectors, PaginatedMessage, TaskEx, extension methods)
• Data folder (created at runtime under bin/Debug/netcoreapp3.1/Data) containing token.txt and rolex.db
• Configuration/deployment files: .gitignore, Dockerfile, GitHub Actions workflow (.github/workflows/dotnet.yml)
README for additional insights
• Sets up a SQLite database via Entity Framework Core
• Reads Discord bot token from Data/token.txt
• No frontend/UI – all interaction via Discord API
Main components, relationships, and key patterns
a. Components:
1. Bot Core (Program.cs → host builder, service registration)
2. Discord Gateway Client (Discord.Net library)
3. InteractionHandler (wires incoming messages/interactions to Services/Commands)
4. Command Modules (each folder under Modules implements ICommand or DiscordCommandClass)
5. Services Layer (common abstractions: SQLite persistence, Redis cache, permission checks, Punishment logic)
6. Utilities (message collectors, pagination, extension methods)
7. Persistence: SQLite (EF Core auto‐migration to rolex.db)
8. Cache: Redis (optional, via RedisClass)
9. External: Discord API (REST + Gateway), Webhooks
b. Relationships & data flow:
• Program.cs starts the Discord client and registers Services & Utilities in the DI container
• Discord Gateway emits an event for a message or interaction → InteractionHandler
• InteractionHandler resolves the matching ICommand/DiscordCommandClass from Services
• Command module executes business logic (may read/write sqlite via Settings or SQLite service, may read/write RedisClass)
• Command may post a response back to Discord (via Discord.Net) or fire a webhook
c. Architectural patterns:
• Modular command pattern – each command in its own class, loaded by reflection or DI
• Dependency Injection – .NET Core built‐in DI container
• Repository/Service abstraction – data access via Service classes (SQLite, Redis)
• Event‐driven – reacting to Discord events
d. Key technologies:
• .NET Core 3.1, C#
• Discord.Net library
• EF Core (SQLite provider)
• Redis (StackExchange.Redis or similar)
• Docker for containerization
• GitHub Actions for CI/CD
Details
• Specific module areas (General, Moderation, Developer, Emojis, Role Editor, Webhooks) as sub‐blocks or annotations
• Service layer interfaces (ICommands, RequiredPermissions) connecting to modules
• That EF Core auto-migrates and persists to rolex.db in the Data folder
• Where token.txt is read at startup for authentication