@@ -5,8 +5,13 @@ namespace Discord.API.Client | |||||
{ | { | ||||
public class MemberPresence : MemberReference | public class MemberPresence : MemberReference | ||||
{ | { | ||||
[JsonProperty("game_id")] | |||||
public string GameId { get; set; } | |||||
public sealed class GameInfo | |||||
{ | |||||
[JsonProperty("name")] | |||||
public string Name { get; set; } | |||||
} | |||||
[JsonProperty("game")] | |||||
public GameInfo 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))] | ||||
@@ -9,9 +9,15 @@ namespace Discord.API.Client.GatewaySocket | |||||
object IWebSocketMessage.Payload => this; | object IWebSocketMessage.Payload => this; | ||||
bool IWebSocketMessage.IsPrivate => false; | bool IWebSocketMessage.IsPrivate => false; | ||||
public sealed class GameInfo | |||||
{ | |||||
[JsonProperty("name")] | |||||
public string Name { get; set; } | |||||
} | |||||
[JsonProperty("idle_since")] | [JsonProperty("idle_since")] | ||||
public long? IdleSince { get; set; } | public long? IdleSince { get; set; } | ||||
[JsonProperty("game_id")] | |||||
public int? GameId { get; set; } | |||||
[JsonProperty("game")] | |||||
public GameInfo Game { get; set; } | |||||
} | } | ||||
} | } |
@@ -60,8 +60,8 @@ namespace Discord | |||||
public string SessionId { get; private set; } | public string SessionId { get; private set; } | ||||
/// <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 this current user is reported as playing. </summary> | |||||
public int? CurrentGameId { get; private set; } | |||||
/// <summary> Gets the game the current user is displayed as playing. </summary> | |||||
public string CurrentGame { get; private set; } | |||||
/// <summary> Gets a collection of all servers this client is a member of. </summary> | /// <summary> Gets a collection of all servers this client is a member of. </summary> | ||||
public IEnumerable<Server> Servers => _servers.Select(x => x.Value); | public IEnumerable<Server> Servers => _servers.Select(x => x.Value); | ||||
@@ -297,14 +297,14 @@ namespace Discord | |||||
Status = status; | Status = status; | ||||
return SendStatus(); | return SendStatus(); | ||||
} | } | ||||
public Task SetGame(int? gameId) | |||||
public Task SetGame(string game) | |||||
{ | { | ||||
CurrentGameId = gameId; | |||||
CurrentGame = game; | |||||
return SendStatus(); | return SendStatus(); | ||||
} | } | ||||
private Task SendStatus() | private Task SendStatus() | ||||
{ | { | ||||
GatewaySocket.SendUpdateStatus(Status == UserStatus.Idle ? EpochTime.GetMilliseconds() - (10 * 60 * 1000) : (long?)null, CurrentGameId); | |||||
GatewaySocket.SendUpdateStatus(Status == UserStatus.Idle ? EpochTime.GetMilliseconds() - (10 * 60 * 1000) : (long?)null, CurrentGame); | |||||
return TaskHelper.CompletedTask; | return TaskHelper.CompletedTask; | ||||
} | } | ||||
@@ -59,7 +59,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 id for the game this user is currently playing. </summary> | /// <summary> Gets the id for the game this user is currently playing. </summary> | ||||
public string GameId { get; private set; } | |||||
public string GameName { get; private set; } | |||||
/// <summary> Gets the current status for this user. </summary> | /// <summary> Gets the current status for this user. </summary> | ||||
public UserStatus Status { get; private set; } | public UserStatus Status { get; private set; } | ||||
/// <summary> Gets the datetime that this user joined this server. </summary> | /// <summary> Gets the datetime that this user joined this server. </summary> | ||||
@@ -195,7 +195,7 @@ namespace Discord | |||||
_lastOnline = DateTime.UtcNow; | _lastOnline = DateTime.UtcNow; | ||||
} | } | ||||
GameId = model.GameId; //Allows null | |||||
GameName = model.Game?.Name; //Allows null | |||||
} | } | ||||
internal void Update(MemberVoiceState model) | internal void Update(MemberVoiceState model) | ||||
{ | { | ||||
@@ -137,8 +137,12 @@ 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, int? gameId) | |||||
=> QueueMessage(new UpdateStatusCommand { IdleSince = idleSince, GameId = gameId }); | |||||
public void SendUpdateStatus(long? idleSince, string gameName) | |||||
=> QueueMessage(new UpdateStatusCommand | |||||
{ | |||||
IdleSince = idleSince, | |||||
Game = gameName != null ? new UpdateStatusCommand.GameInfo { Name = gameName } : 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 }); | ||||
public void SendRequestMembers(ulong serverId, string query, int limit) | public void SendRequestMembers(ulong serverId, string query, int limit) | ||||