Presence()

class Presence(client_id, pipe=0, loop=None, handler=None)

Creates the Presence client ready for usage.

Parameters:
  • client_id (str) – OAuth2 App ID (found here)

  • pipe (int) – Pipe that should be used to connect to the Discord client. Defaults to 0, can be 0-9

  • loop (asyncio.BaseEventLoop) – Your own event loop (if you have one) that PyPresence should use. One will be created if not supplied. Information at https://docs.python.org/3/library/asyncio-eventloop.html

  • handler (function) – The exception handler pypresence should send asynchronous errors to. This can be a coroutine or standard function as long as it takes two arguments (exception, future). Exception will be the exception to handle and future will be an instance of asyncio.Future


connect()

Initializes the connection - must be done in order to make any updates to Rich Presence.

Return type:

pypresence.Response


clear(pid=os.getpid())

Clears the presence.

Parameters:

pid (int) – the process id of your game

Return type:

pypresence.Response


close()

Closes the connection.

Return type:

pypresence.Response


update(**options)

Sets the user’s presence on Discord.

Parameters:
  • pid (int) – the process id of your game

  • state (str) – the user’s current status

  • details (str) – what the player is currently doing

  • start (int) – epoch time for game start

  • end (int) – epoch time for game end

  • large_image (str) – name of the uploaded image for the large profile artwork

  • large_text (str) – tooltip for the large image

  • small_image (str) – name of the uploaded image for the small profile artwork

  • small_text (str) – tootltip for the small image

  • party_id (str) – id of the player’s party, lobby, or group

  • party_size (list) – current size of the player’s party, lobby, or group, and the max in this format: [1,4]

  • join (str) – unique hashed string for chat invitations and ask to join

  • spectate (str) – unique hashed string for spectate button

  • match (str) – unique hashed string for spectate and join

  • buttons (list) – list of dicts for buttons on your profile in the format [{"label": "My Website", "url": "https://qtqt.cf"}, ...], can list up to two buttons

  • instance (bool) – marks the match as a game session with a specific beginning and end

Return type:

pypresence.Response