How techthrives/discordbots works
Project type and purpose
• This is a Node.js “monorepo” hosting two independent Discord bots (“astris-ai” and “muzer”) managed together (turbo.json, root package.json).
• “astris-ai” provides AI-powered text and image commands (uses OpenAI APIs).
• “muzer” provides music playback and playlist management (uses Discord voice API, MongoDB for persistence).
File structure
• Top-level:
• package.json / package-lock.json – root dependencies and scripts (likely for monorepo tooling).
• turbo.json – indicates use of Turborepo for task orchestration.
• bots/astris-ai – one microservice.
• bots/muzer – another microservice.
• Each bot:
• index.js – entry point.
• config.js – environment/config loader.
• commands/ – modular slash‐command handlers.
• events/ – Discord event listeners (ready, interactionCreate, messageCreate).
• helpers/utils – domain logic (OpenAI calls, text/image gen, common utilities).
• deploy-commands.js (.astris-ai) – CLI to register commands with Discord.
• muzer adds mongodb.js, player.js, languages/, ui/ – for persistence, audio pipeline, localization, UI embed styling.
README
• No architectural description (429 error), but file structure and filenames imply the stacks:
• Node.js + Discord.js for both.
• OpenAI API integration in astris-ai.
• MongoDB for muzer.
a. Main components
• Root Monorepo (Turborepo)
• Astris-AI Bot Service
• Muzer Bot Service
• External Services: Discord Gateway & REST API, OpenAI API, MongoDB Cluster, Audio Stream Sources (e.g., YouTube)
b. Relationships and interactions
1. User sends a slash-command or message → Discord Gateway
2. Gateway forwards event → Bot Service (astris-ai or muzer)
3. Event handler dispatches to appropriate Command Module
4. Command Module:
• astris-ai may call helper.textGeneration or helper.imgGeneration → OpenAI API
• muzer may call player.js (audio pipeline) and/or mongodb.js → MongoDB
5. Bot Service sends response (text, embed, image, voice) → Discord API → User
c. Architectural patterns
• Microservices (two independent bots) within one repo
• Event-driven: Discord events trigger handlers
• Modular command pattern (each command is a separate file)
• Helper/utility layering for domain logic separation
d. Key technologies
• Node.js, Discord.js
• Turborepo (mono-repo tooling)
• OpenAI SDK / REST calls (astris-ai)
• MongoDB Node driver (muzer)
• Discord Voice API (muzer)
Detail
• Folder’s role.
• Data flow for a sample command (e.g., “/summarize” → OpenAI).
• Asynchronous event-driven nature.