discord.py exposes Discord's HTTP and Gateway APIs with async/await syntax. It includes optional command and task extensions for building bots in Python 3.8+.
Overview
discord.py is a Python package that wraps Discord's APIs so programs can automate accounts and bots on the platform. The interface is object-oriented and built around modern asyncio patterns with async and await.
Core capabilities cover sending and receiving messages, managing channels and guild structures, handling events, and respecting Discord rate limits automatically. An optional voice extra adds audio features when dependencies are installed on supported platforms.
The discord.ext.commands extension supplies a bot framework with decorators for prefix commands, while discord.ext.tasks helps schedule recurring asyncio work. Documentation covers intents, logging, migrations between major versions, and numerous examples for common bot patterns.
Install via pip for library-only use or with the voice extra when needed. It is a client library that runs inside your Python process rather than a hosted service; you supply bot tokens and hosting for the long-running process.
Key features
- Async/await API design
- Automatic rate limit handling
- Optional voice support extra
- commands extension for bots
- tasks extension for scheduling
- Gateway intents configuration
- Rich event callback model
- Memory and speed optimizations
Use cases
- Discord chat bots
- Community moderation automation
- Interactive server utilities
- Gateway event-driven integrations