Skip to main content

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:

git clone https://gitlab.com/somberdemise/discord-rpc.py
cd discord.py
python -m pip install -U .

Examples

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.1.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distributions

discord_rpc.py-1.1.0-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

discord_rpc.py-1.1.0-py2-none-any.whl (25.7 kB view details)

Uploaded Python 2

File details

Details for the file discord-rpc.py-1.1.0.tar.gz.

File metadata

  • Download URL: discord-rpc.py-1.1.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for discord-rpc.py-1.1.0.tar.gz
Algorithm Hash digest
SHA256 46d9a0e8e6baa5c7cac053af399e2330dbac5be276f92c4ad7d6ef785206d78c
MD5 90d7a3751cf2f9441fecfc01e919fa89
BLAKE2b-256 d8d63d08540c04ca8c2f0a6ad991eaa98a78bcd6f1c8dc33a1bf751bce6a280a

See more details on using hashes here.

File details

Details for the file discord_rpc.py-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: discord_rpc.py-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.7 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/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for discord_rpc.py-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38bdd49e50626d0ee9aab7396ef7250d8680f3f488c5a4712a22fc2c17ded612
MD5 e433cad1e733684824757a2e43cd07e8
BLAKE2b-256 4942fc6e09013cbb4b0e22d6c7387391ecc1421e50831cf324e925740474eda3

See more details on using hashes here.

File details

Details for the file discord_rpc.py-1.1.0-py2-none-any.whl.

File metadata

  • Download URL: discord_rpc.py-1.1.0-py2-none-any.whl
  • Upload date:
  • Size: 25.7 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/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for discord_rpc.py-1.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 825c05832db90854ed2fdf9ab35cb65b8443c847688124d238a4fa056e79b599
MD5 22616209ece513ba56a4872870f99273
BLAKE2b-256 e9ee6b1411f04884cf4e0b308beec3d4611b4af7e73c6bf29bfcfe5ee8501cf7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page