Giter Club home page Giter Club logo

discord-rich-presence's Introduction

discord-rich-presence

A lightweight and safe package for creating custom rich presences on Discord.

Example

Discord Rich Presence Example

How to Use

Making a Discord App

  1. Create an app by clicking "New Application" in the Discord Developers Portal.
  2. Give your app a name and an icon (this can be changed later). Make sure to save your changes.
    • Optional: Go to "Rich Presence", and add a few images under the "Rich Presence Assets" section.
  3. Under "Application Id" in the "General Information" tab, copy your app's id.

Installation

  1. Install the latest version of Python if you haven't already.
  2. Run the following in your terminal:
$ pip install discord-rich-presence

If all goes well, it should say something like "Successfully installed discord-rich-presence".

Writing the Code

  1. Create a file ending in .py, and paste in the following example from examples/simple.py:
from discordrp import Presence
import time

client_id = "000000000000000000"  # Replace this with your own client id

with Presence(client_id) as presence:
    print("Connected")
    presence.set(
        {
            "state": "In Game",
            "details": "Summoner's Rift",
            "timestamps": {"start": int(time.time())},
        }
    )
    print("Presence updated")

    while True:
        time.sleep(15)

Make sure you replace the client_id variable with your app's id that you copied earlier.

  1. Run the program! You should now see that you have a rich presence on your profile that will be on until you stop the program! Feel free to change the code however you want by adding images, buttons, and more. Check out examples/complex.py for another example.

Methods

Here are the methods on a Presence instance:

  • presence.set(activity): Sets the current activity using a dictionary representing a Discord activity object.
  • presence.clear(): Clears the current activity.
  • presence.close(): Closes the current connection. This method is automatically called when the program exits using the with statement.

Troubleshooting

Here are the most common errors:

  • ActivityError: An incorrect dictionary was passed to presence.set. Make sure that it matches the format expected by Discord.
  • ClientIDError: Verify that your client ID is valid.
  • PresenceError: Read the Discord docs for more information.
  • ConnectionRefusedError or FileNotFoundError: Make sure that your Discord application is open and logged in.
  • Program hangs for a long time and does not set the presence: Wait for at least 10 seconds before closing and trying again.

discord-rich-presence's People

Contributors

tentype avatar amund211 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.