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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

discord_rpc.py-1.0.3-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

discord_rpc.py-1.0.3-py2-none-any.whl (24.6 kB view details)

Uploaded Python 2

File details

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

File metadata

  • Download URL: discord_rpc.py-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 24.6 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.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6469b973b8fc439bd71ddd35372019a8455ccbd237597af26182c83537a58480
MD5 9c4656ab02bdbf0d67a10403e40cfdc8
BLAKE2b-256 90c194455dd0e73372df14952c44b9476176fdb25afa7c8dc95c3d22710bc42a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: discord_rpc.py-1.0.3-py2-none-any.whl
  • Upload date:
  • Size: 24.6 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.0.3-py2-none-any.whl
Algorithm Hash digest
SHA256 84744fb40fa1e7caf615ffd7be029d44e5ca35136b5041b60e034003e2696556
MD5 897445964a2199ad2074b95e44401a8b
BLAKE2b-256 5f98547e178bcb79286e237fefbcbd740ddef53302dd22bf1dc85d6dfa555494

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