vionya/discord-rich-presence

[Help] Clearing Activity

Closed this issue · 4 comments

Are you able to clear the activity without closing the connection?
if not, how can i implement this feature in my program

DiscordIpc's implementations of .close all begin by sending a payload with no data and an opcode of 2 to the IPC connection (client.send([JSON value of {}], 2)). You can consider doing this.

is doing it like this wrong?

let data = json!({
                    "cmd": "SET_ACTIVITY",
                    "args": {
                        "pid": std::process::id(),
                        "activity": None::<()>
                    },
                    "nonce": Uuid::new_v4().to_string()
                });
                client.send(data, 1).expect("Failed to clear activity")

got the idea from a python implementation of RPC, pypresence, which basically sends an empty activity with an opcode of 1

If it does the trick then there's probable nothing wrong with it. My first answer was probably wrong - I think it was sending a connection close payload (been a while since I've read the reference for this haha).

I can look into adding a helper for this if necessary.

yeah, it would be awesome if you could add it whenever you can! there's no rush though since there's a workaround for it