Lachee / discord-rpc-csharp

C# custom implementation for Discord Rich Presence. Not deprecated and still available!
MIT License
560 stars 93 forks source link

Added `UpdateButtons` #175

Closed Almighty-Shogun closed 2 years ago

Almighty-Shogun commented 2 years ago

This pull request will allow users to update and remove their buttons without having to restart the program.

You can use this code in the following way:

Updating all the buttons

When a user wants to update all their buttons from the current Rich Presence they can do the following:

client.UpdateButtons(new Button[]
{
    new() { Label = "ButtonLabel 1", Url = "https://domain.com" }, // Button 1
    new() { Label = "ButtonLabel 2", Url = "https://domain.com" } // Button 2
});

Updating a single button

When a user wants to update a single button from the current Rich Presence they can do the following:

Example: You have 2 buttons. The first one is a link to your website and the second one is a link to your Discord server. You want to update the second one with an up-to-date invite link you can do the following code:

client.UpdateButtons(new Button[]
{
    new() { Label = "Join our Discord", Url = "https://discord.com/invite/xxx" }
}, 1);

Removing buttons

When a user want to remove their buttons from the current Rich Presence they can do the following:

client.UpdateButtons();

If there are any follow up questions or things I might have missed let me know and I will look into it asap!

Almighty-Shogun commented 2 years ago

I forgot to mention that there was also an issue for this https://github.com/Lachee/discord-rpc-csharp/issues/147