PyPresence is a Discord RPC client library for Python, enabling developers to integrate their applications with Discord's Rich Presence feature. It supports both synchronous and asynchronous operations for updating a user's status. The current version is 4.6.1, and it typically has releases for bug fixes and new Discord RPC features.
pip install pypresenceVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `pypresence.Presence` for synchronous Rich Presence updates. It connects to Discord, sets a custom presence with details, timestamps, images, and buttons, then maintains it for 30 seconds before disconnecting. Remember to replace `123456789012345678` with your actual Discord Application ID in production, or set the `PYPRESENCE_CLIENT_ID` environment variable.
Ensure the official Discord desktop client is running on your system before running your PyPresence application.
Verify your Client ID in the Discord Developer Portal (Applications -> Your App -> General Information). Ensure the 'Public' toggle is enabled if you want others to see your presence.
Upgrade to pypresence v4.5.2 or newer to benefit from improved IPC pipe detection and connection/disconnection stability. This addresses issues like `get_ipc_path()` when `pipe=0` and broken pipe detection, which were hotfixed in v4.5.2.
For synchronous applications, use `pypresence.Presence`. For asynchronous applications (e.g., with `discord.py` or `asyncio`), use `pypresence.AioPresence` and ensure your code is `await`ed appropriately within an event loop.
Start the Discord desktop client application. If it's already running, try restarting your Python script or Discord. Ensure you have the latest pypresence version for improved pipe detection.
Double-check your `CLIENT_ID` in the Discord Developer Portal (https://discord.com/developers/applications). Copy it directly and ensure it's passed as a string or integer.
Ensure your `CLIENT_ID` is converted to an integer: `Presence(int(CLIENT_ID))` or `AioPresence(int(CLIENT_ID))`. While newer versions might handle string conversion, explicitly converting is safer.
Refer to the pypresence documentation or Discord Rich Presence API for valid keys and their expected types. Common keys include `state`, `details`, `start`, `end`, `large_image`, `large_text`, `small_image`, `small_text`, `buttons`, etc.
No dependency data recorded yet.