Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discord RPC Hook] Set activity type from "Playing" to "Watching" #739

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sitiom
Copy link
Contributor

@sitiom sitiom commented Sep 8, 2024

With qwertyquerty/pypresence#244 merged, this should now be possible. Example (with my custom ID of title Anime):

Before

image
image

After

image
image

@FichteFoll
Copy link
Collaborator

We should definitely stay compatible to older pypresence versions since this change is not even released (last release was 2023-07-08).

@ahmubashshir
Copy link
Contributor

ahmubashshir commented Sep 29, 2024

If possible, we can try detecting if it's supported before actually using it...

diff --git a/hooks/presence.py b/hooks/presence.py
index fd8b393..36f82a8 100644
--- a/hooks/presence.py
+++ b/hooks/presence.py
@@ -13,7 +13,7 @@ from asyncio import new_event_loop as new_loop
 from asyncio import set_event_loop as set_loop
 from threading import Thread
 
-from pypresence import ActivityType
+from importlib.util import find_spec
 from pypresence.client import Client
 from pypresence.exceptions import InvalidID, InvalidPipe
 
@@ -31,6 +31,8 @@ class DiscordRPC(Thread):
     _enabled = False
     _update = False
     regret = True
+    _activity = {} if find_spec('pypresence.types') is None \
+        else {"activity_type": __import__('pypresence.types').ActivityType.WATCHING}
 
     _rpc = None
     _pid = None
@@ -84,7 +86,6 @@ class DiscordRPC(Thread):
                     else:
                         self._rpc.set_activity(
                             pid=self._pid,
-                            activity_type=ActivityType.WATCHING,
                             large_image=self._details['thumb'],
                             large_text=self._details['details'],
                             small_image=self._details['img'],
@@ -92,7 +93,8 @@ class DiscordRPC(Thread):
                             buttons=self._details['buttons'],
                             details=self._details['details'],
                             state=self._details['state'],
-                            start=self._details['start']
+                            start=self._details['start'],
+                            **self._watching
                         )
                     self._update = False
                 time.sleep(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants