dexel-base
Health Warn
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 6 GitHub stars
Code Warn
- network request — Outbound network request in cogs/ai/summarise.py
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
Open-source Discord bot with an autonomous AI agent, ticketing, giveaways, moderation and more.
Dexel Base
A production-grade, multi-purpose Discord bot. Open sourced as a reference implementation of an autonomous AI agent, a self-migrating database layer, and a Discord Components V2 design system.
This is the base edition of Dexel. Every feature here is free and self-hostable. No tiers, no external dashboard, no lock-in. Clone it, run it, learn from it, fork it.
Just want Dexel in your server without hosting it? The hosted bot lives at dexel.tech (docs), and you can add it to Discord in a minute.
What's inside
| Area | Highlights |
|---|---|
| AI agent & BYOK | ReAct loop with parallel tool execution, model cascade and conversation self-repair, 100+ tools across 7 categories, BYOK Key Studio (OpenAI, Gemini, OpenRouter), sub-agent delegation, staged action plans with approval flows, per-user long-term memory, vision and voice input |
| Music system | High-fidelity audio streaming powered by Wavelink 3.x & Lavalink v4. Interactive now-playing cards with live playback controls, queue management, volume, seek, loop, shuffle, and self-contained lavalink/ docker configuration |
| Ticketing | 7-step setup wizard, button panels, AI-answered tickets with a semantic FAQ knowledge base (RAG via embeddings and cosine similarity), staff escalation, auto-close timers, AI-generated resolution summaries |
| Giveaways | Wizard-driven creation, entry gates (roles, activity points, account/server age), weighted ticket multipliers, pause/resume/edit/reroll, split-or-steal mode |
| Moderation | Warn/kick/ban/timeout/purge/lock/slowmode with infraction history, temp-ban scheduler, nickname dehoisting, master audit log (14 raw listeners deduplicated into interactive log cards) |
| Starboard | Raw-reaction listeners, config dashboard, leaderboards, per-guild thresholds and emoji |
| Activity & levels | Hourly/daily/monthly XP rollups, per-channel/role multipliers, role tiers with DM notifications, matplotlib progression graphs |
| Server & utility | PIL-rendered welcome/leave graphics, invite tracking with anti-fake and growth graphs, Reddit/YouTube/GitHub feeds, multi-scope AFK with inbox delivery, instant Google Translate, natural-language reminders with timezones, channel summaries, arXiv research, LeetCode stats, counting game, AI image generation |
Every interactive surface uses Discord Components V2 (LayoutView + Container). No legacy embed-only interfaces.
The agent architecture
The AI subsystem is a compact agent framework:
utils/agent/
├── registry.py Tool registry. @registry.register(...) decorators build
│ Gemini FunctionDeclarations and filter tools per caller
│ by Discord permissions, context (DM vs guild), and
│ guild toggles
├── runner.py The ReAct engine: LLM, then parallel tool calls
│ (asyncio.gather), then LLM again. Includes a model
│ cascade (gemini-3.5-flash-lite, then gemini-3.1-flash-lite,
│ then a gemma fallback), conversation-state self-repair
│ (_sanitize_contents), loop/stall detection, and
│ tool-payload truncation to protect the context window
├── context.py ToolContext: bot, guild, channel, author, db, staged
│ actions, and attached interactive views. Passed to
│ every tool.
└── tools/ ~20 modules registering 100+ tools (admin, moderation,
external/research, discord, memory, support, discovery)
Patterns worth stealing:
- Staged action plans. Destructive or multi-step tool calls (channel restructures, batch moderation) don't execute immediately. The agent stages a plan, the runner attaches a Components V2 approval view, and a human clicks Execute. See
BatchActionPlanViewinmoderation_tools.pyandplanning_tools.py. - Sub-agent delegation. A
delegate_to_specialistmeta-tool lets the coordinator spawn focused sub-agents (server admin, moderation, research, community, support), each with its own system prompt and restricted toolset, recursively up to a bounded depth. - Prompt-injection defense. All external content (web results, scraped pages, user profiles) is wrapped in
<untrusted_*>boundary tags with explicit handling rules injected at prompt-build time (build_dynamic_system_promptinutils/llm.py). - Recovery hints. When a tool errors, the registry appends a
recovery_hintto the error payload so the LLM can self-correct on the next turn instead of hallucinating success. - Memory distillation. After a chat goes idle, a background LLM pass distills the conversation into dated, categorized long-term memory per user (
utils/memory_manager.py). - Token accounting. Every LLM call is metered per user and per guild against the daily quotas in
hyperparams.py, with an 80% warning card.
Project structure
dexel-base/
├── bot.py Bot client: intents, asyncpg pool, self-migration,
│ dynamic cog loader (walks cogs/), global rate-limit
│ check, global error handling, command sync
├── config.py Frozen dataclass reading .env: tokens, IDs, prompts
├── hyperparams.py Every tunable limit / cadence / budget in one file
├── lavalink/ Lavalink v4 server: docker-compose.yml & application.yml
├── cogs/
│ ├── ai/ /ai chat|setup|usage|reset|keys|models, /summarize,
│ │ /paper, /imagine, DM + bound-channel agent listeners
│ ├── games/ /counting setup|reset|stats|disable math minigame
│ ├── meta/ /help (hand-crafted catalog), /getstarted, /about,
│ │ /invite, /ping, guild join/leave onboarding flows
│ ├── moderation/ /autolog, /dehoist, /nuke, /slowmode, /ban, /kick,
│ │ /timeout, /warn, /modlogs
│ ├── server/ /activity, /greeting, /invites, /server
│ └── utility/ /play, /queue, /nowplaying (music), /afk, /translate,
│ /starboard, /feed, /ticket, /remind, /transcribe,
│ /profile, /settings, /leetcode
├── utils/
│ ├── agent/ The agent framework (see above)
│ ├── db/ Modular asyncpg DatabaseManager with domain mixins:
│ │ activity, afk, ai, autolog, counting, feeds,
│ │ giveaway, moderation, reminders, starboard, tickets
│ ├── ui.py Components V2 design system (cards, paginators,
│ │ confirmations, welcome views)
│ ├── llm.py LLMHelper, personas, embeddings, dynamic prompts
│ ├── llm_pool.py Multi-provider client pool (Gemini, OpenAI, OpenRouter)
│ ├── crypto.py AES-GCM encryption for user BYOK API keys
│ ├── rate_limiter.py Sliding windows (user/guild/AI-global), blacklists
│ ├── error_logger.py Discord error-channel sink + logging handler
│ └── ... activity cache, feeds service, image generator,
│ transcriber, time parser, invite graph, etc.
└── assets/ Welcome-card & canvas templates + Inter font
Database: plain PostgreSQL via asyncpg, no ORM, no vendor lock-in. Any Postgres 14+ DSN works (local Docker, Supabase, Neon, Railway). All tables and indexes are created idempotently at startup (CREATE TABLE IF NOT EXISTS inside DatabaseManager.create_tables()), so there is no migration script to run. Ever.
hyperparams.py
All operational knobs live in hyperparams.py and are wired into the code that enforces them:
- Rate limits: user (5 cmds/10s), guild (25/10s), bot-wide AI (30/min)
- Quotas: per-user daily AI tokens (500k), per-guild pool (1M)
- Feature limits: feeds per guild (25), reminders per user (50), ticket FAQs (10)
- Cadences: giveaway check loop (15s), reminder dispatch (10s), ticket auto-close (1 min)
- Agent budgets: max ReAct iterations (8), sub-agent depth (6), tool-payload truncation, chat-history turns
Change a number, restart the bot. Done.
Self-hosting
1. Prerequisites
- Python 3.11+ (developed and tested on 3.14)
- PostgreSQL 14+. The quickest option is Docker:
docker run -d --name dexel-db -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=dexel -p 5432:5432 postgres:16 - Lavalink v4 (for music streaming). A ready-to-run container is included:
cd lavalink && docker compose up -d && cd .. - A Discord application. Create one at discord.com/developers/applications
2. Configure the Discord application
- Open your application's Bot page, click Reset Token, and copy the token. This is
DISCORD_TOKEN. - Still on the Bot page, enable the three Privileged Gateway Intents: Server Members, Message Content, and Presence. Activity tracking, AI listeners, and onboarding all need them.
- Copy the Application ID from the General Information page. This is
CLIENT_ID; it powers the invite links. - Invite the bot with your client ID substituted:
https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=2182138944&integration_type=0&scope=bot+applications.commands
3. Configure the bot
git clone https://github.com/theadityasinghal/dexel-base.git
cd dexel-base
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
# now edit .env:
# DISCORD_TOKEN (required)
# DATABASE_URL (required) e.g. postgresql://postgres:postgres@localhost:5432/dexel
# GOOGLE_LLM_API (required for AI features) https://aistudio.google.com/apikey
# OWNER_ID (recommended: enables owner tools and immunities)
# CLIENT_ID (recommended: enables invite links)
4. Run
python bot.py
On start the bot connects to Postgres and creates every table it needs, loads all cogs from cogs/, and syncs its slash commands. Sync is instant to your GUILD_ID if set, otherwise global; a first-time global sync can take up to an hour to propagate.
Try /help, then /ticket config or /ai setup to see the interactive dashboards.
5. Optional keys
| Key | Unlocks |
|---|---|
GROQ_API_KEY |
/transcribe + AI voice-message understanding |
POLLINATIONS_API_KEY |
/imagine + the generate_image agent tool |
REDDIT_CLIENT_ID / REDDIT_CLIENT_SECRET |
Reddit as a source in /feed config (YouTube & GitHub feeds need no keys) |
Without GOOGLE_LLM_API the bot still runs. Every AI surface degrades gracefully and everything else works normally.
Troubleshooting
Database connection attempt failed: check the DSN. Local Postgres hosts are auto-detected and skip SSL; remote hosts require TLS. On Supabase, prefer the Connection Pooler URI (port 6543); the directdb.<ref>.supabase.co:5432host is IPv6-only.- Commands don't appear: without
GUILD_ID, the first global sync can take up to an hour. For instant iteration, setGUILD_IDto your test server. CommandSyncFailureat startup: Discord caps command names at 32 chars and descriptions at 100. If you added or edited a command, check its decorators.403 Forbidden ... error log channel: the bot lost access to a configured log channel. Unset the corresponding*_CHANNEL_IDor restore its access.
Contributing & community
Contributions are welcome! Please read our CONTRIBUTING.md guidelines and CODE_OF_CONDUCT.md before getting started. Security vulnerabilities should be reported according to SECURITY.md.
For release history and version notes, see CHANGELOG.md. For in-depth architectural conventions (cog structure, Components V2 rules, database patterns, startup gotchas), refer to AGENTS.md.
Join our Discord Community to discuss development, get help with self-hosting, or share feedback.
License
MIT, © 2026 Aditya Singhal. Dexel is open sourced in the hope that its patterns (agent orchestration, staged action plans, self-migrating SQL, and a Components V2 design system) are useful to other bot developers.
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found