@@ -70,6 +70,9 @@ | |||||
<Compile Include="..\Discord.Net\API\Client\Common\ExtendedMember.cs"> | <Compile Include="..\Discord.Net\API\Client\Common\ExtendedMember.cs"> | ||||
<Link>API\Client\Common\ExtendedMember.cs</Link> | <Link>API\Client\Common\ExtendedMember.cs</Link> | ||||
</Compile> | </Compile> | ||||
<Compile Include="..\Discord.Net\API\Client\Common\Game.cs"> | |||||
<Link>API\Client\Common\Game.cs</Link> | |||||
</Compile> | |||||
<Compile Include="..\Discord.Net\API\Client\Common\Guild.cs"> | <Compile Include="..\Discord.Net\API\Client\Common\Guild.cs"> | ||||
<Link>API\Client\Common\Guild.cs</Link> | <Link>API\Client\Common\Guild.cs</Link> | ||||
</Compile> | </Compile> | ||||
@@ -520,6 +523,9 @@ | |||||
<Compile Include="..\Discord.Net\Models\Color.cs"> | <Compile Include="..\Discord.Net\Models\Color.cs"> | ||||
<Link>Models\Color.cs</Link> | <Link>Models\Color.cs</Link> | ||||
</Compile> | </Compile> | ||||
<Compile Include="..\Discord.Net\Models\Game.cs"> | |||||
<Link>Models\Game.cs</Link> | |||||
</Compile> | |||||
<Compile Include="..\Discord.Net\Models\Invite.cs"> | <Compile Include="..\Discord.Net\Models\Invite.cs"> | ||||
<Link>Models\Invite.cs</Link> | <Link>Models\Invite.cs</Link> | ||||
</Compile> | </Compile> | ||||
@@ -602,7 +608,6 @@ | |||||
<Link>TaskManager.cs</Link> | <Link>TaskManager.cs</Link> | ||||
</Compile> | </Compile> | ||||
<Compile Include="Enums\GameType.cs" /> | <Compile Include="Enums\GameType.cs" /> | ||||
<Compile Include="Models\Game.cs" /> | |||||
<Compile Include="Properties\AssemblyInfo.cs" /> | <Compile Include="Properties\AssemblyInfo.cs" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -1,8 +1,8 @@ | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
namespace Discord | |||||
namespace Discord.API.Client | |||||
{ | { | ||||
public class GameInfo | |||||
public class Game | |||||
{ | { | ||||
[JsonProperty("game")] | [JsonProperty("game")] | ||||
public string Name { get; set; } | public string Name { get; set; } |
@@ -6,7 +6,7 @@ namespace Discord.API.Client | |||||
public class MemberPresence : MemberReference | public class MemberPresence : MemberReference | ||||
{ | { | ||||
[JsonProperty("game")] | [JsonProperty("game")] | ||||
public GameInfo Game { get; set; } | |||||
public Game Game { get; set; } | |||||
[JsonProperty("status")] | [JsonProperty("status")] | ||||
public string Status { get; set; } | public string Status { get; set; } | ||||
[JsonProperty("roles"), JsonConverter(typeof(LongStringArrayConverter))] | [JsonProperty("roles"), JsonConverter(typeof(LongStringArrayConverter))] | ||||
@@ -12,6 +12,6 @@ namespace Discord.API.Client.GatewaySocket | |||||
[JsonProperty("idle_since")] | [JsonProperty("idle_since")] | ||||
public long? IdleSince { get; set; } | public long? IdleSince { get; set; } | ||||
[JsonProperty("game")] | [JsonProperty("game")] | ||||
public GameInfo Game { get; set; } | |||||
public Game Game { get; set; } | |||||
} | } | ||||
} | } |
@@ -65,7 +65,7 @@ namespace Discord | |||||
/// <summary> Gets the status of the current user. </summary> | /// <summary> Gets the status of the current user. </summary> | ||||
public UserStatus Status { get; private set; } | public UserStatus Status { get; private set; } | ||||
/// <summary> Gets the game the current user is displayed as playing. </summary> | /// <summary> Gets the game the current user is displayed as playing. </summary> | ||||
public GameInfo CurrentGame { get; private set; } | |||||
public Game CurrentGame { get; private set; } | |||||
/// <summary> Gets a collection of all extensions added to this DiscordClient. </summary> | /// <summary> Gets a collection of all extensions added to this DiscordClient. </summary> | ||||
public IEnumerable<IService> Services => _services; | public IEnumerable<IService> Services => _services; | ||||
@@ -319,18 +319,19 @@ namespace Discord | |||||
Status = status; | Status = status; | ||||
SendStatus(); | SendStatus(); | ||||
} | } | ||||
public void SetGame(GameInfo game) | |||||
public void SetGame(Game game) | |||||
{ | { | ||||
CurrentGame = game; | CurrentGame = game; | ||||
SendStatus(); | 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(); | SendStatus(); | ||||
} | } | ||||
private void SendStatus() | private void SendStatus() | ||||
@@ -1,9 +1,22 @@ | |||||
namespace Discord | 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; | |||||
} | |||||
} | } | ||||
} | } |
@@ -23,7 +23,7 @@ namespace Discord | |||||
/// <summary> Gets an id uniquely identifying from others with the same name. </summary> | /// <summary> Gets an id uniquely identifying from others with the same name. </summary> | ||||
public ushort Discriminator => Client.PrivateUser.Discriminator; | public ushort Discriminator => Client.PrivateUser.Discriminator; | ||||
/// <summary> Gets the name of the game this user is currently playing. </summary> | /// <summary> Gets the name of the game this user is currently playing. </summary> | ||||
public GameInfo CurrentGame => Client.PrivateUser.CurrentGame; | |||||
public Game? CurrentGame => Client.PrivateUser.CurrentGame; | |||||
/// <summary> Gets the current status for this user. </summary> | /// <summary> Gets the current status for this user. </summary> | ||||
public UserStatus Status => Client.PrivateUser.Status; | public UserStatus Status => Client.PrivateUser.Status; | ||||
/// <summary> Returns the string used to mention this user. </summary> | /// <summary> Returns the string used to mention this user. </summary> | ||||
@@ -63,7 +63,7 @@ namespace Discord | |||||
/// <summary> Gets the unique identifier for this user's current avatar. </summary> | /// <summary> Gets the unique identifier for this user's current avatar. </summary> | ||||
public string AvatarId { get; private set; } | public string AvatarId { get; private set; } | ||||
/// <summary> Gets the name of the game this user is currently playing. </summary> | /// <summary> Gets the name of the game this user is currently playing. </summary> | ||||
public GameInfo CurrentGame { get; internal set; } | |||||
public Game? CurrentGame { get; internal set; } | |||||
/// <summary> Determines whether this user is a Bot account. </summary> | /// <summary> Determines whether this user is a Bot account. </summary> | ||||
public bool IsBot { get; internal set; } | public bool IsBot { get; internal set; } | ||||
/// <summary> Gets the current status for this user. </summary> | /// <summary> Gets the current status for this user. </summary> | ||||
@@ -207,8 +207,11 @@ namespace Discord | |||||
if (Status == UserStatus.Offline) | if (Status == UserStatus.Offline) | ||||
_lastOnline = DateTime.UtcNow; | _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) | internal void Update(MemberVoiceState model) | ||||
{ | { | ||||
@@ -11,6 +11,7 @@ using System.IO; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using APIGame = Discord.API.Client.Game; | |||||
namespace Discord.Net.WebSockets | namespace Discord.Net.WebSockets | ||||
{ | { | ||||
@@ -167,11 +168,11 @@ namespace Discord.Net.WebSockets | |||||
=> QueueMessage(new ResumeCommand { SessionId = SessionId, Sequence = _lastSequence }); | => QueueMessage(new ResumeCommand { SessionId = SessionId, Sequence = _lastSequence }); | ||||
public override void SendHeartbeat() | public override void SendHeartbeat() | ||||
=> QueueMessage(new HeartbeatCommand()); | => QueueMessage(new HeartbeatCommand()); | ||||
public void SendUpdateStatus(long? idleSince, GameInfo game) | |||||
public void SendUpdateStatus(long? idleSince, Game? game) | |||||
=> QueueMessage(new UpdateStatusCommand | => QueueMessage(new UpdateStatusCommand | ||||
{ | { | ||||
IdleSince = idleSince, | 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) | public void SendUpdateVoice(ulong? serverId, ulong? channelId, bool isSelfMuted, bool isSelfDeafened) | ||||
=> QueueMessage(new UpdateVoiceCommand { GuildId = serverId, ChannelId = channelId, IsSelfMuted = isSelfMuted, IsSelfDeafened = isSelfDeafened }); | => QueueMessage(new UpdateVoiceCommand { GuildId = serverId, ChannelId = channelId, IsSelfMuted = isSelfMuted, IsSelfDeafened = isSelfDeafened }); | ||||