I’ve been working on a Discord bot that developer communities can self-host: it analyzes code, generates docs, explains errors, and even inspects GitHub repos, all via slash commands and powered by OpenAI. I’ve open-sourced it and wanted to share what it does and how it’s built.
What it does
The bot exposes six slash commands. No need for the bot to read every message; everything is interaction-based.
-
/analyze-code— Paste a code snippet. You get the detected language, potential issues, refactoring ideas, and quality/security notes. -
/generate-docs— Paste code and get generated documentation: what it does, parameters, return values, and usage examples. -
/error-explain— Paste an error or stack trace and get a plain-language explanation plus suggested fixes. -
/explain— Ask for an explanation of a concept (e.g. “async await”) at Beginner, Intermediate, or Senior level. -
/github-analyze— Pass a public GitHub repo URL. You get a tech stack summary, project structure overview, and improvement suggestions. -
/project-health— Same repo URL. You get recent commit activity, contributor overview, and a short “health” summary.
User activity (e.g. which commands are used) is tracked in MongoDB for a simple skill/usage view; the data stays with whoever hosts the bot.
Tech stack
- Node.js + TypeScript — Typed, maintainable code.
- discord.js — Slash commands and interactions; no privileged intents.
- OpenAI API (gpt-3.5-turbo) — All the “understanding” and text generation.
- MongoDB (Mongoose) — User and usage data for the scoring idea.
The repo includes setup guides: Discord app configuration, env vars, optional GitHub token for the repo commands, and how to run it locally or in production.
Why this structure
I wanted something that’s easy to extend: one place for command definitions, one for handlers, and separate services for GitHub, OpenAI, and user logic. New commands are just a new definition + handler + optional service. There’s an Architecture doc in the repo for contributors.
Try it or contribute
Everything is on GitHub: Discord Developer Assistant. It’s MIT licensed. The README and /docs folder cover:
- Discord Developer Portal setup (which intents and permissions to enable)
- Optional GitHub token for
/github-analyzeand/project-health - MongoDB (local or Atlas)
- Build and run commands
If you run a dev community on Discord or just want to tinker with a bot that uses OpenAI and the GitHub API, feel free to clone it, open issues, or send PRs. I’d love to hear what you’d add next.
Top comments (0)