A previous release had provenance metadata, but this release does not. View details.
Install • Features • Comparison • Quick Start • Report Bug
Dopamine Framework is a framework for discord.py which allows you to initialize a production-ready Discord bot in just 4 lines of code. In technical terms, this is can be described as a "Flexible" Boilerplate Framework (not to be confused with opinionated boilerplate framework). It is designed to streamline the development of scalable Discord applications by automating the process of registering commands and simplify the process of creating them, diagnosing the bot, and various other utilities such as a paginator helper and "Private View" helpers which let only the user who initiated the interaction to interact with the components like buttons.
A Dopamine Studios product.
Installing
Use Python 3.12 or higher:
# Linux/MacOS
python3 -m pip install -U dopamine-framework
# Windows
py -3 -m pip install -U dopamine-framework
Features
1. Smart Command Syncing
The framework includes a Command Registry that compares local command states with remote Discord API states. This ensures that global and guild-specific slash commands are only synced when changes are detected, preventing unnecessary API overhead and rate-limit triggers.
2. Dopamine Commands decorator with Preconditions
The @dopamine_commands.command decorator replaces the standard discord.py version, allowing you to define permissions and cooldowns in a single line.
- Simplified Syntax: Define name, description, permissions, and cooldowns within one decorator.
- Implicit Global Cooldown: Every command is protected by the bot's global rate limit by default.
- Group Support: Use
dopamine_commands.Groupto apply permissions or cooldowns to an entire category of subcommands at once.
from dopamineframework import dopamine_commands
@dopamine_commands.command(
name="ban",
permissions_preset="moderator",
global_cooldown=True
)
async def ban_member(interaction: discord.Interaction, member: discord.Member):
await member.ban()
await interaction.response.send_message(f"{member.display_name} has been banned.")
3. Precondition Decorators
If you prefer using standard app_commands, you can use the standalone @preconditions decorators to enforce rules dynamically.
- Permission Presets: Use pre-defined roles like
"admin","moderator", or"support"instead of manual permission bitfields. - Advanced Logic: Includes
has_permissions_any(pass if user has one of many) andhas_permissions(must have all). - Smart Rate Limiting: Easily implement command-specific or bot-wide global cooldowns to prevent spam.
| Preset | Required Permissions |
|---|---|
"bot_owner" |
Restricts usage to the bot owner/team owners. |
moderator |
Manage Messages, Kick Members, Ban Members |
admin |
Administrator |
giveaways |
Manage Guild, Manage Messages |
automation |
Manage Guild, Manage Messages, Manage Channels |
manager |
Manage Guild, Manage Roles, Manage Channels |
support |
Manage Messages, Read Message History |
security |
View Audit Log, Moderate Members |
community |
Manage Expressions, Manage Threads, Create Public Threads |
technical |
Manage Webhooks, Manage Guild |
4. In-Discord Owner Dashboard
No need for terminal access/SSH. This simple to use and feature-rich dashboard for bot owners allows you to unload/reload cogs on the fly, restart the bot, or check logs, accessed using /od. This allows bot owner(s) to manage, diagnose the bot right within Discord itself. This dashboard allows the bot to run idefinitely without restarts:
- Cog Management: Dynamic loading, unloading, and reloading of cogs.
- Power State: Remote shutdown and process-level restarts.
- Logs: Real-time retrieval of log files via the Discord UI.
- Manual Command Syncs: Sync commands manually globally or within only the current guild.
5. Diagnostics
The built-in Diagnostics "cog" (module) provides real-time monitoring of the bot's health, including:
- Latency: High precision API, Heartbeat, and Round-trip latency monitoring.
- Resource Utilization: CPU and RAM usage tracking via
psutil. - Graphs: Generate graphs for the bot's latency for visual performance auditing.
- Host Device Metrics: Integration with system sensors to report host location and battery status, if available.
6. Built-in Logging Backend
- A robust Logging Manager utilizing
aiosqlitethat can be plugged into any feature of your bot to implement a logging system, such as for mod logs, action logs, etc.
Comparison (with Sapphire Framework and standard discord.py)
| Feature | Dopamine Framework | Sapphire (js/ts) | discord.py |
|---|---|---|---|
| Easy Setup | ✅ (minimal boilerplate) |
❌ (Lots of boilerplate) |
❌ |
| Preconditions Support | ✅ | ✅ | ❌ |
| Presets for Permission Checks in Preconditions |
✅ | ❌ | ❌ |
| No tantrums over different structure | ✅ | ❌ | ✅ |
| Python's ease of use | ✅ | ❌ | ✅ |
| Smart Commands Sync | ✅ (Built-in) |
✅ (Through plugins) |
❌ (not included/standard) |
| In-Discord Dashboard | ✅ (Built-in) |
❌ | ❌ |
| Latency Graphs | ✅ (Built-in) |
❌ | ❌ |
| Scalability* | ✅ | ✅ | ✅ |
| Fast Iteration | ✅ | ❌ | ❌ |
| Strict TypeScript Rules | ❌ | ✅ | ❌ |
| Built-in Resource Monitoring | ✅ | ❌ | ❌ |
| Is it JS, tho? | ❌ | ✅ | ❌ |
| Wins Imaginary Benchmarks | ❌ | ✅ | ❌ |
| Gives you that Dopamine rush? | ✅ (Built-in) |
❌ | ❌ |
*Scalability refers to ability to run without problems when the bot is in tens of thousands of servers or more. While it's a common myth that "Python is bloated", that's not true in the context of Discord bots. The real bottleneck in popular Discord bots always comes down to network, not code execution time or memory usage.
Implementation Example
To initialize a bot using the Dopamine Framework, follow the following example:
import discord
from dopamineframework import Bot
bot = Bot(command_prefix="?", cogs_path="your cogs/modules folder path here*", logging_path="path to .sqlite, .db, or .db3 file; only define if you want to use this logging backend.", default_diagnostics=True, intents=discord.Intents.default()) # If no cogs folder is defined, it will default to "cogs". If no logging path, logging will be disabled.
bot.run("YOUR_BOT_TOKEN_HERE")
*Note: All .py files will be attempted to be loaded in the folder. It's recommended to only use the defined path for cogs/extensions/modules.
Requirements
discord.pyaiosqlitepsutilPillowgeocoder
License & Attribution
Dopamine Framework is licensed under the Apache License 2.0.
How to Credit
While you are free to use this framework for private or commercial bots, I require explicit credit. Please include a link to this repository or a mention of "Dopamine Framework" in:
- Your project's README or documentation.
- Your bot's info/credits command (for example
/aboutor/help).
Example: "Built with Dopamine Framework"
Metadata
Release files for dopamine-framework 2.2.2.post4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Loss of provenance
These files do not have provenance metadata, despite files in a prior release including this data.
We recommend further investigation before installing these files. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dopamine_framework-2.2.2.post4.tar.gz | 175.7 kB | Without provenance | Details for dopamine_framework-2.2.2.post4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dopamine_framework-2.2.2.post4-py3-none-any.whl | Python 3 | none | any | Details for dopamine_framework-2.2.2.post4-py3-none-any.whl |
Total release size: 356.6 kB
Release files / dopamine_framework-2.2.2.post4.tar.gz
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | dopamine_framework-2.2.2.post4.tar.gz |
|---|---|
| Size | 175.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
113d6456c0416495418dcd76b798d778dfd8b8dc72985887c5d801586f07d7d6
|
|
BLAKE2b-256 checksum How to use checksums |
bd39f14b79b093088537d81838973f8724d8b20792d20945f94c5a21491d0662
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / dopamine_framework-2.2.2.post4-py3-none-any.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | dopamine_framework-2.2.2.post4-py3-none-any.whl |
|---|---|
| Size | 180.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4176ad1cca2653bf9dfa8a4e72429e613dcc4f1866d4c37c6b54fbee7395cfc
|
|
BLAKE2b-256 checksum How to use checksums |
b5284e4d8ff52407575824bb408a04be61528af51f56cea56fc6dd50c2daa44e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for dopamine-framework 2.2.2.post4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Loss of provenance
A previous release of these files had provenance metadata, but this release does not.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Release comparison
- Removed 2.2.2 2 files With provenance
- Added 2.2.2.post4 2 files Without provenance
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.