Senophyx / Discord-RPC

An Python wrapper for Discord RPC
https://pypi.org/project/discord-rpc
MIT License
26 stars 9 forks source link

Add the ability to display the listening status #28

Closed chicco-carone closed 1 month ago

chicco-carone commented 5 months ago

For some discord applications like spotify and in general media consumption discord has the abilty to display "is listening/watching" with a progress bar and albums/cover art. I can't seem to find a way to recreate this by using this library or the javascript one.

pazkero commented 5 months ago

For that, you need to change the ActivityType

As far as I know, you cannot set this with RPC. You need the GameSDK and I'm not aware of any way to use it with Python.

Senophyx commented 5 months ago

For that, you need to change the ActivityType

As far as I know, you cannot set this with RPC. You need the GameSDK and I'm not aware of any way to use it with Python.

Thank you so much Pazkero for the reply.

Yes, I've looked for references about RPC activities other than "playing" but there are no implementation examples either in Python or other programming languages ​​(for standalone programs without using GameSDK). Therefore this feature will not be implemented in the near future until Discord makes suitable documentation or there are examples from other people.

fixator10 commented 1 month ago

You just need to add "type" field to activity object Adding "type": 2, after this line Produces this RPC: Listening to <AppName>

Docs: https://discord.com/developers/docs/rich-presence/using-with-the-embedded-app-sdk#setactivity-fields https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-types

Senophyx commented 1 month ago

Thank you @fixator10 for the solution.

Yes, i can confirm this Activity Type works on current code of Discord-RPC. And I will implement this feature in the next version of Discord-RPC (5.1). However, I still cannot implement Activity Type 1 (streaming) and 4 (custom). But I will still release version 5.1 by not allowing using Activity Type 1 and 4 until this issue is fixed in the future.

Senophyx commented 1 month ago

Added to the main code (#cb0806d).

This issue will be closed again and will be updated when the Activity Types 1 and 4 issues are fixed.

chicco-carone commented 2 weeks ago

Added to the main code (#cb0806d).

This issue will be closed again and will be updated when the Activity Types 1 and 4 issues are fixed.

@Senophyx i tried to create a listening status with the library which works fine but if you use the listening status there is no way to set the timebar with the progress for the listening status or a way to set the album image to be from an url or a file but only the image method that uses the one from the developer page which is a fixed image.

Senophyx commented 2 weeks ago

if you use the listening status there is no way to set the timebar with the progress for the listening status

just add ts_start and ts_end to add the time bar. image

import discordrpc
from discordrpc import utils

rpc = discordrpc.RPC(app_id=123456789)

rpc.set_activity(
      state="A super simple rpc",
      details="simple RPC",
      act_type=2,
      ts_start=utils.timestamp,
      ts_end=1726723833
    )

# Required if you only run Discord RPC on this file or current instance.
rpc.run()

a way to set the album image to be from an url or a file

i think you can't because you have to upload it first through the developer page.

Senophyx commented 2 weeks ago

@all-contributors please add @fixator10 for doc

allcontributors[bot] commented 2 weeks ago

@Senophyx

I've put up a pull request to add @fixator10! :tada: