/// <summary> /// Sets the end time of the <see cref="CurrentPresence"/> and sends the updated presence to Discord. /// </summary> /// <param name="time">The new time for the end</param> /// <returns>Updated Rich Presence</returns> public RichPresence UpdateEndTime(DateTime time) { if (!IsInitialized) { throw new UninitializedException(); } //Clone the presence RichPresence presence; lock (_sync) { if (CurrentPresence == null) { presence = new RichPresence(); } else { presence = CurrentPresence.Clone(); } } //Update the value if (presence.Timestamps == null) { presence.Timestamps = new Timestamps(); } presence.Timestamps.End = time; SetPresence(presence); return(presence); }
/// <summary> /// Sets the start and end time of <see cref="CurrentPresence"/> to null and sends it to Discord. /// </summary> /// <returns>Updated Rich Presence</returns> public RichPresence UpdateClearTime() { if (!IsInitialized) { throw new UninitializedException(); } //Clone the presence RichPresence presence; lock (_sync) { if (CurrentPresence == null) { presence = new RichPresence(); } else { presence = CurrentPresence.Clone(); } } //Update the value presence.Timestamps = null; SetPresence(presence); return(presence); }
/// <summary> /// Updates the <see cref="Secrets"/> of the <see cref="CurrentPresence"/> and sends the updated presence to Discord. Will override previous secret entirely. /// </summary> /// <param name="secrets">The new secret to send to discord.</param> /// <returns>Updated Rich Presence</returns> public RichPresence UpdateSecrets(Secrets secrets) { if (!IsInitialized) { throw new UninitializedException(); } //Clone the presence RichPresence presence; lock (_sync) { if (CurrentPresence == null) { presence = new RichPresence(); } else { presence = CurrentPresence.Clone(); } } //Update the value presence.Secrets = secrets; SetPresence(presence); return(presence); }
/// <summary> /// Updates the small <see cref="Assets"/> of the <see cref="CurrentPresence"/> and sends the updated presence to Discord. Both <paramref name="key"/> and <paramref name="tooltip"/> are optional and will be ignored it null. /// </summary> /// <param name="key">Optional: The new key to set the asset too</param> /// <param name="tooltip">Optional: The new tooltip to display on the asset</param> /// <returns>Updated Rich Presence</returns> public RichPresence UpdateSmallAsset(string key = null, string tooltip = 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 value if (presence.Assets == null) { presence.Assets = new Assets(); } presence.Assets.SmallImageKey = key ?? presence.Assets.SmallImageKey; presence.Assets.SmallImageText = tooltip ?? presence.Assets.SmallImageText; SetPresence(presence); return(presence); }
/// <summary> /// Updates the <see cref="Party.Size"/> of the <see cref="CurrentPresence"/> and sends the update presence to Discord. Returns the newly edited Rich Presence. /// <para>Will return null if no presence exists and will throw a new <see cref="NullReferenceException"/> if the Party does not exist.</para> /// </summary> /// <param name="size">The new size of the party. It cannot be greater than <see cref="Party.Max"/></param> /// <param name="max">The new size of the party. It cannot be smaller than <see cref="Party.Size"/></param> /// <returns>Updated Rich Presence</returns> public RichPresence UpdatePartySize(int size, int max) { if (!IsInitialized) { throw new UninitializedException(); } //Clone the presence RichPresence presence; lock (_sync) { if (CurrentPresence == null) { presence = new RichPresence(); } else { presence = CurrentPresence.Clone(); } } //Ensure it has a party if (presence.Party == null) { throw new BadPresenceException("Cannot set the size of the party if the party does not exist"); } //Update the value presence.Party.Size = size; presence.Party.Max = max; SetPresence(presence); return(presence); }
/// <summary> /// Updates only the <see cref="RichPresence.Party"/> of the <see cref="CurrentPresence"/> and sends the updated presence to Discord. Returns the newly edited Rich Presence. /// </summary> /// <param name="party">The party of the Rich Presence</param> /// <returns>Updated Rich Presence</returns> public RichPresence UpdateParty(Party party) { if (!IsInitialized) { throw new UninitializedException(); } //Clone the presence RichPresence presence; lock (_sync) { if (CurrentPresence == null) { presence = new RichPresence(); } else { presence = CurrentPresence.Clone(); } } //Update the value presence.Party = party; SetPresence(presence); return(presence); }
/// <summary> /// Updates only the <see cref="RichPresence.Details"/> of the <see cref="CurrentPresence"/> and sends the updated presence to Discord. Returns the newly edited Rich Presence. /// </summary> /// <param name="details">The details of the Rich Presence</param> /// <returns>Updated Rich Presence</returns> public RichPresence UpdateDetails(string details) { if (!IsInitialized) { throw new UninitializedException(); } //Clone the presence RichPresence presence; lock (_sync) { if (CurrentPresence == null) { presence = new RichPresence(); } else { presence = CurrentPresence.Clone(); } } //Update the value presence.Details = details; SetPresence(presence); return(presence); }