diff --git a/DOCS.md b/DOCS.md index 4691dcd..dc9f58f 100644 --- a/DOCS.md +++ b/DOCS.md @@ -41,7 +41,7 @@ Step-by-step making simple rich presence using Discord-RPC. import discordrpc ``` -3. Creating `rpc` variable from `discordrpc.RPC`. And insert your app ID ([Tutorial](#getting-application-id)). +3. Creating `rpc` variable from `discordrpc.RPC` with your unique ([Application ID](#getting-application-id)). ```py rpc = discordrpc.RPC(app_id=1234) #Change app_id to your app id ``` @@ -66,39 +66,42 @@ Step-by-step making simple rich presence using Discord-RPC. Examples can be seen in the repository (`Discord-RPC/examples`) or [here](https://github.com/Senophyx/Discord-RPC/tree/main/examples). -## **All class and function** +## **All classes and functions** ## class `discordrpc.RPC()` - `discordrpc.RPC()`

Parameters : - app_id (`int`) : Application ID ([Tutorial](#getting-application-id)) - - debug (`bool`) : Print more informative output. Default = False - - output (`bool`) : Print output or not. Default = True + - debug (`bool`) : Whether to include debug information in the output. Default = False + - output (`bool`) : Whether to print the output. Default = True - exit_on_disconnect (`bool`) : Whether to quit program when disconnecting. Default = True - method `RPC.set_activity()`
Set activity to be displayed on the user's Discord profile.
+ See [Activity Object](https://discord.com/developers/docs/events/gateway-events#activity-object) Discord documentation page for more details. + Keep in mind that not every field is currently implemented. Parameters : - - state (`str`) - - details (`str`) - - act_type (`discordrpc.Activity`) : [Activity Types](#class-discordrpcactivity) (Activity Type `1` and `4` is currently disabled, see [#28](https://github.com/Senophyx/Discord-RPC/issues/28#issuecomment-2301287350)). - - state_url (`str`) : URL that is linked when clicking on the state text. - - details_url (`str`) : URL that is linked when clicking on the details text. - - ts_start (`int`) : Timestamp start. - - ts_end (`int`) : Timestamp end. - - large_image (`str`) : The name of the image that has been uploaded to the Discord Developer Portal. - - large_text (`str`) : Text when user hover to `large_image`. - - small_image (`str`) : The name of the image that has been uploaded to the Discord Developer Portal. - - small_text (`str`) : Text when user hover to `small_image`. - - party_id (`int`) : id of the user’s party. - - party_size (`list`) : party size in list with format `[current_size, max_size]` or `[1, 10]`. + - state (`str`) - Describes user's current party status. + - details (`str`) - Describes what the player is currently doing. + - act_type (`discordrpc.Activity`) : An [Activity Type](https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-types). Controls how the user's activity is described in their status (e.g. Playing Foo, Listening to Foo). (`Streaming` and `Custom` are currently disabled, see [#28](https://github.com/Senophyx/Discord-RPC/issues/28#issuecomment-2301287350)) + - status_type (`discordrpc.StatusDisplay`) : A [Status Display Type](https://discord.com/developers/docs/events/gateway-events#activity-object-status-display-types). Controls what is displayed in the user's activity status (e.g. Listening to Foo, Listening to Bar) + - ts_start (`int`) : Timestamp representing the start time of an activity. Represented in UNIX epoch time, in seconds. + - ts_end (`int`) : Timestamp representing the end time of an activity. Represented in UNIX epoch time, in seconds. When specified, a progress bar is displayed going from `ts_start` to `ts_end`. + - large_image (`str`) : Either a unique name of an asset in your application, or a URL to an image. See [Activity Asset Image](https://discord.com/developers/docs/events/gateway-events#activity-object-activity-asset-image). + - large_text (`str`) : Text shown when hovering over `large_image`. + - large_url (`str`) : URL opened when clicking on `large_image`. + - small_image (`str`) : Either a unique name of an asset in your application, or a URL to an image. See [Activity Asset Image](https://discord.com/developers/docs/events/gateway-events#activity-object-activity-asset-image). + - small_text (`str`) : Text shown when hovering over `small_image`. + - small_url (`str`) : URL opened when clicking on `small_url`. + - party_id (`int`) : ID of the user’s party. + - party_size (`list`) : Party size in list with format `[current_size, max_size]` or `[1, 10]`. - join_secret (`str`) : Secret for chat invitations and ask to join button. - spectate_secret (`str`) : Secret for spectate button. - - match_secret (`str`) : Secret for for spectate and join button - - buttons (`list`) : list of dicts for buttons on user's profile. You can use [`discordrpc.Button`](#function-discordrpcbutton) for more easier. + - match_secret (`str`) : Secret for for spectate and join button. + - buttons (`list`) : A `list` of `dicts` for buttons on user's profile. A helper object `discordrpc.Button(text:str, url:str)` is provided. - Return : `True` if rpc successfully connected. + Returns : `True` if RPC successfully connected. - method `RPC.clear()`
Clear activity status. @@ -108,10 +111,10 @@ Examples can be seen in the repository (`Discord-RPC/examples`) or [here](https: - method `RPC.disconnect()`
Disconnecting and closing RPC socket. - Return : nothing. + Returns : `None`. - method `RPC.run()`
- Keeping rpc alive. Not required if another tasks is running on the same file. + Keeping the RPC alive. Not required if another tasks is running on the same file. Parameters : - update_every (`int`) : `time.sleep` every inputed second. @@ -119,7 +122,7 @@ Examples can be seen in the repository (`Discord-RPC/examples`) or [here](https: Exceptions : - `KeyboardInterrupt` will call `RPC.disconnect`. - Return : nothing. + Returns : `None`. - variable `self.is_connected`
Check whether the RPC successfully handshaked and connected to the Discord socket. @@ -150,9 +153,17 @@ Examples can be seen in the repository (`Discord-RPC/examples`) or [here](https: - Competing > [!NOTE] -> Activity Type `Streaming` and `Custom` currently disabled.
+> Types `Streaming` and `Custom` are currently disabled.
> [Details](https://github.com/Senophyx/Discord-RPC/issues/28#issuecomment-2301287350) +## class `discordrpc.Activity` +- Enum `StatusDisplay`
+ Simplified StatusDisplay type payload in `RPC.set_activity` + + Available values : + - Name + - State + - Details ## function `discordrpc.Button()` - Simplified button payload in `RPC.set_activity` @@ -161,7 +172,7 @@ Examples can be seen in the repository (`Discord-RPC/examples`) or [here](https: - text (`str`) - url (`str`) - Return : Payload dict. + Returns : Payload dict. > [!NOTE] > Discord does not display buttons in your own Activity.
diff --git a/discordrpc/presence.py b/discordrpc/presence.py index 80744ad..4e07d78 100644 --- a/discordrpc/presence.py +++ b/discordrpc/presence.py @@ -53,13 +53,13 @@ def _setup(self): def set_activity( self, - state: str=None, details:str=None, act_type:Activity=Activity.Playing, + state: str=None, details:str=None, act_type:Activity=Activity.Playing, status_type:StatusDisplay=StatusDisplay.Name, + large_image:str=None, large_text:str=None, large_url:str=None, + small_image:str=None, small_text:str=None, small_url:str=None, state_url:str=None, details_url:str=None, ts_start:int=None, ts_end:int=None, # progressbar:dict=None, # use_local_time:bool=False, - large_image:str=None, large_text:str=None, - small_image:str=None, small_text:str=None, party_id:str=None, party_size:list=None, join_secret:str=None, spectate_secret:str=None, match_secret:str=None, buttons:list=None, @@ -83,6 +83,7 @@ def set_activity( "state": state, "details": details, "type": act_type.value, + "status_display_type": status_type.value, "state_url": state_url, "details_url": details_url, "timestamps": { @@ -92,8 +93,10 @@ def set_activity( "assets": { "large_image": large_image, "large_text": large_text, + "large_url": large_url, "small_image": small_image, - "small_text": small_text + "small_text": small_text, + "small_url": small_url }, "party": { "id": party_id, diff --git a/discordrpc/types.py b/discordrpc/types.py index 540462e..f7744bb 100644 --- a/discordrpc/types.py +++ b/discordrpc/types.py @@ -10,6 +10,10 @@ class Activity(Enum): Custom = 4 Competing = 5 +class StatusDisplay(Enum): + Name = 0 + State = 1 + Details = 2 class User(): def __init__(self, data:dict=None):