diff --git a/DiscordRPC/Entities/RichPresence.cs b/DiscordRPC/Entities/RichPresence.cs index 18371b56..32c6134c 100644 --- a/DiscordRPC/Entities/RichPresence.cs +++ b/DiscordRPC/Entities/RichPresence.cs @@ -13,6 +13,24 @@ namespace DiscordRPC [Serializable] public class BaseRichPresence { + /// + /// The application name shown after "Playing/Listening to/Watching/Competing in". + /// Max 128 characters + /// + [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] + public string Name + { + get { return _name; } + set + { + if (!ValidateString(value, out _name, false, 128)) + throw new StringOutOfRangeException("Name", 0, 128); + } + } + + /// Internal inner name string + protected internal string _name; + /// /// The user's current status. For example, "Playing Solo" or "With Friends". /// Max 128 characters @@ -28,7 +46,7 @@ public string State } } - /// Inernal inner state string + /// Internal inner state string protected internal string _state; /// @@ -48,7 +66,7 @@ public string StateUrl throw new ArgumentException("Url must be a valid URI"); } } - /// Inernal inner state URL string + /// Internal inner state URL string protected internal string _stateUrl; /// @@ -65,7 +83,7 @@ public string Details throw new StringOutOfRangeException(128); } } - /// Inernal inner detail string + /// Internal inner detail string protected internal string _details; /// @@ -85,7 +103,7 @@ public string DetailsUrl throw new ArgumentException("Url must be a valid URI"); } } - /// Inernal inner detail URL string + /// Internal inner detail URL string protected internal string _detailsUrl; /// @@ -230,7 +248,8 @@ internal virtual bool Matches(RichPresence other) if (other == null) return false; - if (State != other.State || + if (Name != other.Name || + State != other.State || StateUrl != other.StateUrl || Details != other.Details || DetailsUrl != other.DetailsUrl || @@ -265,7 +284,7 @@ internal virtual bool Matches(RichPresence other) return false; } - //Checks if the timestamps are different + //Checks if the party is different if (Party != null) { if (other.Party == null || @@ -307,6 +326,7 @@ internal virtual bool Matches(RichPresence other) public RichPresence ToRichPresence() { var presence = new RichPresence(); + presence.Name = Name; presence.State = State; presence.StateUrl = StateUrl; presence.Details = Details; @@ -367,6 +387,16 @@ public bool HasButtons() #region Builder /// + /// Sets the name of the Rich Presence. See also . + /// + /// The name of the application. + /// The modified Rich Presence. + public RichPresence WithName(string name) + { + Name = name; + return this; + } + /// /// Sets the state of the Rich Presence. See also . /// /// The user's current status. @@ -511,6 +541,7 @@ public RichPresence Clone() { return new RichPresence { + Name = this._name != null ? _name.Clone() as string : null, State = this._state != null ? _state.Clone() as string : null, StateUrl = this._stateUrl != null ? _stateUrl.Clone() as string : null, Details = this._details != null ? _details.Clone() as string : null, @@ -561,6 +592,7 @@ public RichPresence Clone() /// self internal RichPresence Merge(BaseRichPresence presence) { + this._name = presence.Name; this._state = presence.State; this._stateUrl = presence.StateUrl; this._details = presence.Details; @@ -638,12 +670,5 @@ internal sealed class RichPresenceResponse : BaseRichPresence /// [JsonProperty("application_id")] public string ClientID { get; private set; } - - /// - /// Name of the bot - /// - [JsonProperty("name")] - public string Name { get; private set; } - } }