A Discord Rich Presence library for Python 2 & 3
Project description
# discord-rpc.py
> A Discord RPC library for Python 2 & 3.
# Installation
Install discord-rpc.py with **`pip`**
For the latest stable version:
> `pip install discord-rpc.py`
For the latest development version:
```python
git clone https://gitlab.com/somberdemise/discord-rpc.py
cd discord.py
python -m pip install -U .
```
# Examples
```python
import discord_rpc
import time
if __name__ == '__main__':
def readyCallback(current_user):
print('Our user: {}'.format(current_user))
def disconnectedCallback(codeno, codemsg):
print('Disconnected from Discord rich presence RPC. Code {}: {}'.format(
codeno, codemsg
))
def errorCallback(errno, errmsg):
print('An error occurred! Error {}: {}'.format(
errno, errmsg
))
# Note: 'event_name': callback
callbacks = {
'ready': readyCallback,
'disconnected': disconnectedCallback,
'error': errorCallback,
}
discord_rpc.initialize('token', callbacks=callbacks, log=False)
i = 0
start = time.time()
while i < 10:
i += 1
discord_rpc.update_presence(
**{
'details': 'Iteration # {}'.format(i),
'start_timestamp': start,
'large_image_key': 'default'
}
)
discord_rpc.update_connection()
time.sleep(2)
discord_rpc.run_callbacks()
discord_rpc.shutdown()
```
> A Discord RPC library for Python 2 & 3.
# Installation
Install discord-rpc.py with **`pip`**
For the latest stable version:
> `pip install discord-rpc.py`
For the latest development version:
```python
git clone https://gitlab.com/somberdemise/discord-rpc.py
cd discord.py
python -m pip install -U .
```
# Examples
```python
import discord_rpc
import time
if __name__ == '__main__':
def readyCallback(current_user):
print('Our user: {}'.format(current_user))
def disconnectedCallback(codeno, codemsg):
print('Disconnected from Discord rich presence RPC. Code {}: {}'.format(
codeno, codemsg
))
def errorCallback(errno, errmsg):
print('An error occurred! Error {}: {}'.format(
errno, errmsg
))
# Note: 'event_name': callback
callbacks = {
'ready': readyCallback,
'disconnected': disconnectedCallback,
'error': errorCallback,
}
discord_rpc.initialize('token', callbacks=callbacks, log=False)
i = 0
start = time.time()
while i < 10:
i += 1
discord_rpc.update_presence(
**{
'details': 'Iteration # {}'.format(i),
'start_timestamp': start,
'large_image_key': 'default'
}
)
discord_rpc.update_connection()
time.sleep(2)
discord_rpc.run_callbacks()
discord_rpc.shutdown()
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
discord-rpc.py-1.0.1.tar.gz
(16.6 kB
view details)
Built Distributions
File details
Details for the file discord-rpc.py-1.0.1.tar.gz
.
File metadata
- Download URL: discord-rpc.py-1.0.1.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d90047aaf67fba4f1814d0992c1a1e53632f596eaad8a973c2dd83dbc88e9b96 |
|
MD5 | e63b958819cc2541376207588770f222 |
|
BLAKE2b-256 | 2620eb129e150fba0d2895da39c92da8cfc97633cde7f99bc460489def5c6876 |
File details
Details for the file discord_rpc.py-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: discord_rpc.py-1.0.1-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c98944cbeb8a0eeaf37bef4064293bd945bb8ff347fd6986a8a0e65a2f266d3 |
|
MD5 | d77661b56ef3827f2d5db9e5df6a336a |
|
BLAKE2b-256 | 13e089296a4b5440901a0b50df412ff7eff2b64e1c861162a0e776c0956e93e4 |
File details
Details for the file discord_rpc.py-1.0.1-py2-none-any.whl
.
File metadata
- Download URL: discord_rpc.py-1.0.1-py2-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d348e8a1b87267bff4fe4ca068f40047c40be57f1540b8276885f244d7411c62 |
|
MD5 | 7ea935ccc2c3f654c63bfa3b56a3fa9f |
|
BLAKE2b-256 | 620e01c9e774d1f5613ec01b10c21b1e0aa36e5d8fab17e8b949497c69316645 |