How projectedengg/jayce works
Project Type and Purpose
• This is a backend–only Java application implementing a Discord bot (“Jayce”) with GitHub integration.
• Its primary function is to listen for Discord events (messages, channel actions), respond to slash commands, schedule and run cleanup jobs in Discord channels, and query GitHub issues/repos.
File-Structure Analysis
• Top-level:
• pom.xml – Maven build file (dependencies include JDA or Discord4J, a GitHub API client, a scheduler)
• start.sh – startup shell script
• transfer-issue – likely a helper script for GitHub issue transfers
• src/main/java/gg/projecteden/jayce/:
• Jayce.java – entry point (bootstraps Discord client, scheduler, command registry)
• commands/ – command-handling classes (e.g., ChannelAppCommand, IssuesAppCommand)
• listeners/ – event listeners for Discord events (e.g., IssueLinkListener)
• config/ – configuration holders (aliases, bot config)
• github/ – wrappers around GitHub API calls (Repos, Issues)
• models/scheduledjobs/jobs/ – job classes executed on schedule (ChannelDeleteJob, MessageDeleteJob, etc.)
• utils/ – shared utilities
a. Discord Client Module
• Connects to Discord Gateway via JDA (or Discord4J).
• Dispatches raw events to listener layer.
b. Command Handler
• Registers slash commands at startup.
• Receives command events → routes to specific Command class in commands/*.
c. Event Listeners
• Subscribes to message/update events → triggers link parsing, support-channel archiving, etc.
d. GitHub Integration
• Issues and Repos classes wrap GitHub REST API calls.
• Invoked by commands (e.g., /issues) or link listener.
e. Scheduler
• A scheduled-task engine (Quartz or JDK scheduler)
• Executes scheduled jobs (e.g., cleaning up old messages or channels).
f. Configuration
• Holds bot token, command aliases, scheduling parameters.
Relationships and Data Flow
• User on Discord issues a slash command or posts a message → Discord Gateway → Discord Client → Command Handler or Event Listener.
• Command Handler may call GitHub Integration module → external GitHub REST API → parse response → send embed/message via Discord Client → back to user.
• Scheduler triggers Job classes on a cron or fixed delay → Job reads config → performs cleanup via Discord Client API.
• Configuration is read at startup and injected into all modules.
Architectural Patterns and Principles
• Layered structure:
• Core layer (Jayce.java, Config)
• API layer (github/)
• Presentation layer (listeners/, commands/)
• Infrastructure (scheduler, utils/)
• Command pattern for slash-command implementations.
• Observer pattern for event listeners.
• Dependency injection (manual or via small factory in Jayce.java).
Final Checklist
• Callouts for key technologies (Java 17+, Maven, JDA/Discord4J, GitHub API).
• Layer boundaries (e.g., Presentation, Business Logic, Infrastructure).