diff --git a/src/Discord.Net.Net45/Discord.Net.csproj b/src/Discord.Net.Net45/Discord.Net.csproj
index 35ac7701e..6281ff4e4 100644
--- a/src/Discord.Net.Net45/Discord.Net.csproj
+++ b/src/Discord.Net.Net45/Discord.Net.csproj
@@ -70,6 +70,9 @@
API\Client\Common\ExtendedMember.cs
+
+ API\Client\Common\Game.cs
+
API\Client\Common\Guild.cs
@@ -520,6 +523,9 @@
Models\Color.cs
+
+ Models\Game.cs
+
Models\Invite.cs
@@ -602,7 +608,6 @@
TaskManager.cs
-
diff --git a/src/Discord.Net.Net45/Models/Game.cs b/src/Discord.Net/API/Client/Common/Game.cs
similarity index 83%
rename from src/Discord.Net.Net45/Models/Game.cs
rename to src/Discord.Net/API/Client/Common/Game.cs
index 721486222..5c440b6ee 100644
--- a/src/Discord.Net.Net45/Models/Game.cs
+++ b/src/Discord.Net/API/Client/Common/Game.cs
@@ -1,8 +1,8 @@
using Newtonsoft.Json;
-namespace Discord
+namespace Discord.API.Client
{
- public class GameInfo
+ public class Game
{
[JsonProperty("game")]
public string Name { get; set; }
diff --git a/src/Discord.Net/API/Client/Common/MemberPresence.cs b/src/Discord.Net/API/Client/Common/MemberPresence.cs
index fa8dd06e6..331bbe730 100644
--- a/src/Discord.Net/API/Client/Common/MemberPresence.cs
+++ b/src/Discord.Net/API/Client/Common/MemberPresence.cs
@@ -6,7 +6,7 @@ namespace Discord.API.Client
public class MemberPresence : MemberReference
{
[JsonProperty("game")]
- public GameInfo Game { get; set; }
+ public Game Game { get; set; }
[JsonProperty("status")]
public string Status { get; set; }
[JsonProperty("roles"), JsonConverter(typeof(LongStringArrayConverter))]
diff --git a/src/Discord.Net/API/Client/GatewaySocket/Commands/UpdateStatus.cs b/src/Discord.Net/API/Client/GatewaySocket/Commands/UpdateStatus.cs
index 5adf3ada8..4ebe5633b 100644
--- a/src/Discord.Net/API/Client/GatewaySocket/Commands/UpdateStatus.cs
+++ b/src/Discord.Net/API/Client/GatewaySocket/Commands/UpdateStatus.cs
@@ -12,6 +12,6 @@ namespace Discord.API.Client.GatewaySocket
[JsonProperty("idle_since")]
public long? IdleSince { get; set; }
[JsonProperty("game")]
- public GameInfo Game { get; set; }
+ public Game Game { get; set; }
}
}
diff --git a/src/Discord.Net/DiscordClient.cs b/src/Discord.Net/DiscordClient.cs
index 7b67af4cf..81560d0ef 100644
--- a/src/Discord.Net/DiscordClient.cs
+++ b/src/Discord.Net/DiscordClient.cs
@@ -65,7 +65,7 @@ namespace Discord
/// Gets the status of the current user.
public UserStatus Status { get; private set; }
/// Gets the game the current user is displayed as playing.
- public GameInfo CurrentGame { get; private set; }
+ public Game CurrentGame { get; private set; }
/// Gets a collection of all extensions added to this DiscordClient.
public IEnumerable Services => _services;
@@ -319,18 +319,19 @@ namespace Discord
Status = status;
SendStatus();
}
- public void SetGame(GameInfo game)
+ public void SetGame(Game game)
{
CurrentGame = game;
SendStatus();
}
- public void SetGame(string game, string url = null, GameType type = GameType.Default)
+ public void SetGame(string game)
{
- CurrentGame = new GameInfo() {
- Name = game,
- Url = url ?? CurrentGame?.Url,
- Type = type
- };
+ CurrentGame = new Game(game);
+ SendStatus();
+ }
+ public void SetGame(string game, GameType type, string url)
+ {
+ CurrentGame = new Game(game, type, url);
SendStatus();
}
private void SendStatus()
diff --git a/src/Discord.Net/Models/Game.cs b/src/Discord.Net/Models/Game.cs
index 83109d12c..0c7c25be3 100644
--- a/src/Discord.Net/Models/Game.cs
+++ b/src/Discord.Net/Models/Game.cs
@@ -1,9 +1,22 @@
namespace Discord
{
- public class GameInfo
+ public struct Game
{
- public string Name { get; set; }
- public string Url { get; set; }
- public GameType Type { get; set; }
+ public string Name { get; }
+ public string Url { get; }
+ public GameType Type { get; }
+
+ public Game(string name)
+ {
+ Name = name;
+ Url = null;
+ Type = GameType.Default;
+ }
+ public Game(string name, GameType type, string url)
+ {
+ Name = name;
+ Url = url;
+ Type = type;
+ }
}
}
diff --git a/src/Discord.Net/Models/Profile.cs b/src/Discord.Net/Models/Profile.cs
index 245d45072..ce67e16e0 100644
--- a/src/Discord.Net/Models/Profile.cs
+++ b/src/Discord.Net/Models/Profile.cs
@@ -23,7 +23,7 @@ namespace Discord
/// Gets an id uniquely identifying from others with the same name.
public ushort Discriminator => Client.PrivateUser.Discriminator;
/// Gets the name of the game this user is currently playing.
- public GameInfo CurrentGame => Client.PrivateUser.CurrentGame;
+ public Game? CurrentGame => Client.PrivateUser.CurrentGame;
/// Gets the current status for this user.
public UserStatus Status => Client.PrivateUser.Status;
/// Returns the string used to mention this user.
diff --git a/src/Discord.Net/Models/User.cs b/src/Discord.Net/Models/User.cs
index ba43f439f..1dd1daa94 100644
--- a/src/Discord.Net/Models/User.cs
+++ b/src/Discord.Net/Models/User.cs
@@ -63,7 +63,7 @@ namespace Discord
/// Gets the unique identifier for this user's current avatar.
public string AvatarId { get; private set; }
/// Gets the name of the game this user is currently playing.
- public GameInfo CurrentGame { get; internal set; }
+ public Game? CurrentGame { get; internal set; }
/// Determines whether this user is a Bot account.
public bool IsBot { get; internal set; }
/// Gets the current status for this user.
@@ -207,8 +207,11 @@ namespace Discord
if (Status == UserStatus.Offline)
_lastOnline = DateTime.UtcNow;
}
-
- CurrentGame = model.Game; //Allows null
+
+ if (model.Game != null)
+ CurrentGame = new Game(model.Game.Name, model.Game.Type, model.Game.Url);
+ else
+ CurrentGame = null;
}
internal void Update(MemberVoiceState model)
{
diff --git a/src/Discord.Net/Net/WebSockets/GatewaySocket.cs b/src/Discord.Net/Net/WebSockets/GatewaySocket.cs
index ddfa3d3e5..33f890878 100644
--- a/src/Discord.Net/Net/WebSockets/GatewaySocket.cs
+++ b/src/Discord.Net/Net/WebSockets/GatewaySocket.cs
@@ -11,6 +11,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using APIGame = Discord.API.Client.Game;
namespace Discord.Net.WebSockets
{
@@ -167,11 +168,11 @@ namespace Discord.Net.WebSockets
=> QueueMessage(new ResumeCommand { SessionId = SessionId, Sequence = _lastSequence });
public override void SendHeartbeat()
=> QueueMessage(new HeartbeatCommand());
- public void SendUpdateStatus(long? idleSince, GameInfo game)
+ public void SendUpdateStatus(long? idleSince, Game? game)
=> QueueMessage(new UpdateStatusCommand
{
IdleSince = idleSince,
- Game = game != null ? new GameInfo { Name = game.Name, Url = game.Url, Type = game.Type } : null
+ Game = game != null ? new APIGame { Name = game.Value.Name, Type = game.Value.Type, Url = game.Value.Url } : null
});
public void SendUpdateVoice(ulong? serverId, ulong? channelId, bool isSelfMuted, bool isSelfDeafened)
=> QueueMessage(new UpdateVoiceCommand { GuildId = serverId, ChannelId = channelId, IsSelfMuted = isSelfMuted, IsSelfDeafened = isSelfDeafened });