Skip to content
Open
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
51 changes: 38 additions & 13 deletions DiscordRPC/Entities/RichPresence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ namespace DiscordRPC
[Serializable]
public class BaseRichPresence
{
/// <summary>
/// The application name shown after "Playing/Listening to/Watching/Competing in".
/// <para>Max 128 characters</para>
/// </summary>
[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);
}
}

/// <summary>Internal inner name string</summary>
protected internal string _name;

/// <summary>
/// The user's current <see cref="Party"/> status. For example, "Playing Solo" or "With Friends".
/// <para>Max 128 characters</para>
Expand All @@ -28,7 +46,7 @@ public string State
}
}

/// <summary>Inernal inner state string</summary>
/// <summary>Internal inner state string</summary>
protected internal string _state;

/// <summary>
Expand All @@ -48,7 +66,7 @@ public string StateUrl
throw new ArgumentException("Url must be a valid URI");
}
}
/// <summary>Inernal inner state URL string</summary>
/// <summary>Internal inner state URL string</summary>
protected internal string _stateUrl;

/// <summary>
Expand All @@ -65,7 +83,7 @@ public string Details
throw new StringOutOfRangeException(128);
}
}
/// <summary>Inernal inner detail string</summary>
/// <summary>Internal inner detail string</summary>
protected internal string _details;

/// <summary>
Expand All @@ -85,7 +103,7 @@ public string DetailsUrl
throw new ArgumentException("Url must be a valid URI");
}
}
/// <summary>Inernal inner detail URL string</summary>
/// <summary>Internal inner detail URL string</summary>
protected internal string _detailsUrl;

/// <summary>
Expand Down Expand Up @@ -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 ||
Expand Down Expand Up @@ -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 ||
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -367,6 +387,16 @@ public bool HasButtons()

#region Builder
/// <summary>
/// Sets the name of the Rich Presence. See also <seealso cref="BaseRichPresence.Name"/>.
/// </summary>
/// <param name="name">The name of the application.</param>
/// <returns>The modified Rich Presence.</returns>
public RichPresence WithName(string name)
{
Name = name;
return this;
}
/// <summary>
/// Sets the state of the Rich Presence. See also <seealso cref="BaseRichPresence.State"/>.
/// </summary>
/// <param name="state">The user's current <see cref="Party"/> status.</param>
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -561,6 +592,7 @@ public RichPresence Clone()
/// <returns>self</returns>
internal RichPresence Merge(BaseRichPresence presence)
{
this._name = presence.Name;
this._state = presence.State;
this._stateUrl = presence.StateUrl;
this._details = presence.Details;
Expand Down Expand Up @@ -638,12 +670,5 @@ internal sealed class RichPresenceResponse : BaseRichPresence
/// </summary>
[JsonProperty("application_id")]
public string ClientID { get; private set; }

/// <summary>
/// Name of the bot
/// </summary>
[JsonProperty("name")]
public string Name { get; private set; }

}
}