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

[Help] Clearing Activity #13

Closed
Rayrsn opened this issue Aug 23, 2022 · 4 comments
Closed

[Help] Clearing Activity #13

Rayrsn opened this issue Aug 23, 2022 · 4 comments

Comments

@Rayrsn
Copy link

Rayrsn commented Aug 23, 2022

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

@vionya
Copy link
Owner

vionya commented Aug 25, 2022

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.

@vionya vionya closed this as completed Aug 25, 2022
@Rayrsn
Copy link
Author

Rayrsn commented Aug 25, 2022

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

@vionya
Copy link
Owner

vionya commented Aug 25, 2022

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.

@Rayrsn
Copy link
Author

Rayrsn commented Aug 25, 2022

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

Toldoven added a commit to Toldoven/discord-rich-presence that referenced this issue Sep 1, 2022
vionya added a commit that referenced this issue Sep 8, 2022
Added `clear_activity` method #13 and fixed `connected` bool not working #14
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

No branches or pull requests

2 participants