Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions DiscordRPC/DiscordRpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,74 @@ public void SetPresence(RichPresence presence)
}

#region Updates

/// <summary>
/// Updates only the <see cref="BaseRichPresence.Buttons"/> of the <see cref="CurrentPresence"/> and updates/removes the buttons. Returns the newly edited Rich Presence.
/// </summary>
/// <param name="Button">The buttons of the Rich Presence</param>
/// <returns>Updated Rich Presence</returns>
public RichPresence UpdateButtons(Button[] button = null)
{
if (!IsInitialized)
{
throw new UninitializedException();
}

// Clone the presence
RichPresence presence;
lock (_sync)
{
if (CurrentPresence == null)
{
presence = new RichPresence();
}
else
{
presence = CurrentPresence.Clone();
}
}

// Update the buttons.
presence.Buttons = button;
SetPresence(presence);

return presence;
}

/// <summary>
/// Updates only the <see cref="BaseRichPresence.Buttons"/> of the <see cref="CurrentPresence"/> and updates the button with the given index. Returns the newly edited Rich Presence.
/// </summary>
/// <param name="Button">The buttons of the Rich Presence</param>
/// <param name="Index">The number of the button</param>
/// <returns>Updated Rich Presence</returns>
public RichPresence SetButton(Button button, int index = 0)
{
if (!IsInitialized)
{
throw new UninitializedException();
}

// Clone the presence
RichPresence presence;
lock (_sync)
{
if (CurrentPresence == null)
{
presence = new RichPresence();
}
else
{
presence = CurrentPresence.Clone();
}
}

// Update the buttons
presence.Buttons[index] = button;
SetPresence(presence);

return presence;
}

/// <summary>
/// Updates only the <see cref="BaseRichPresence.Details"/> of the <see cref="CurrentPresence"/> and sends the updated presence to Discord. Returns the newly edited Rich Presence.
/// </summary>
Expand Down