| @@ -604,6 +604,8 @@ | |||||
| <Compile Include="..\Discord.Net\TaskManager.cs"> | <Compile Include="..\Discord.Net\TaskManager.cs"> | ||||
| <Link>TaskManager.cs</Link> | <Link>TaskManager.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="Enums\GameType.cs" /> | |||||
| <Compile Include="Models\Game.cs" /> | |||||
| <Compile Include="Properties\AssemblyInfo.cs" /> | <Compile Include="Properties\AssemblyInfo.cs" /> | ||||
| </ItemGroup> | </ItemGroup> | ||||
| <ItemGroup> | <ItemGroup> | ||||
| @@ -0,0 +1,8 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public enum GameType : int | |||||
| { | |||||
| Default = 0, // "NotStreaming", pretty much | |||||
| Twitch | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,9 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class GameInfo | |||||
| { | |||||
| public string Name { get; set; } | |||||
| public string Url { get; set; } | |||||
| public GameType Type { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -5,11 +5,6 @@ namespace Discord.API.Client | |||||
| { | { | ||||
| public class MemberPresence : MemberReference | public class MemberPresence : MemberReference | ||||
| { | { | ||||
| public class GameInfo | |||||
| { | |||||
| [JsonProperty("name")] | |||||
| public string Name { get; set; } | |||||
| } | |||||
| [JsonProperty("game")] | [JsonProperty("game")] | ||||
| public GameInfo Game { get; set; } | public GameInfo Game { get; set; } | ||||
| [JsonProperty("status")] | [JsonProperty("status")] | ||||
| @@ -9,12 +9,6 @@ namespace Discord.API.Client.GatewaySocket | |||||
| object IWebSocketMessage.Payload => this; | object IWebSocketMessage.Payload => this; | ||||
| bool IWebSocketMessage.IsPrivate => false; | bool IWebSocketMessage.IsPrivate => false; | ||||
| public 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")] | [JsonProperty("game")] | ||||
| @@ -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 string CurrentGame { get; private set; } | |||||
| public GameInfo 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; | ||||
| @@ -316,11 +316,20 @@ namespace Discord | |||||
| Status = status; | Status = status; | ||||
| SendStatus(); | SendStatus(); | ||||
| } | } | ||||
| public void SetGame(string game) | |||||
| public void SetGame(GameInfo game) | |||||
| { | { | ||||
| CurrentGame = game; | CurrentGame = game; | ||||
| SendStatus(); | SendStatus(); | ||||
| } | } | ||||
| public void SetGame(string game, string url = null, GameType type = 0) | |||||
| { | |||||
| CurrentGame = new GameInfo() { | |||||
| Name = game, | |||||
| Url = url ?? CurrentGame.Url, | |||||
| Type = type | |||||
| }; | |||||
| SendStatus(); | |||||
| } | |||||
| private void SendStatus() | private void SendStatus() | ||||
| { | { | ||||
| PrivateUser.Status = Status; | PrivateUser.Status = Status; | ||||
| @@ -0,0 +1,8 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public enum GameType : int | |||||
| { | |||||
| Default = 0, // "NotStreaming", pretty much | |||||
| Twitch | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,9 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class GameInfo | |||||
| { | |||||
| public string Name { get; set; } | |||||
| public string Url { get; set; } | |||||
| public GameType Type { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -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 string CurrentGame => Client.PrivateUser.CurrentGame; | |||||
| public GameInfo 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 string CurrentGame { get; internal set; } | |||||
| public GameInfo 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> | ||||
| @@ -208,7 +208,7 @@ namespace Discord | |||||
| _lastOnline = DateTime.UtcNow; | _lastOnline = DateTime.UtcNow; | ||||
| } | } | ||||
| CurrentGame = model.Game?.Name; //Allows null | |||||
| CurrentGame = model.Game; //Allows null | |||||
| } | } | ||||
| internal void Update(MemberVoiceState model) | internal void Update(MemberVoiceState model) | ||||
| { | { | ||||
| @@ -167,11 +167,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, string gameName) | |||||
| public void SendUpdateStatus(long? idleSince, GameInfo game) | |||||
| => QueueMessage(new UpdateStatusCommand | => QueueMessage(new UpdateStatusCommand | ||||
| { | { | ||||
| IdleSince = idleSince, | IdleSince = idleSince, | ||||
| Game = gameName != null ? new UpdateStatusCommand.GameInfo { Name = gameName } : null | |||||
| Game = game != null ? new GameInfo { Name = game.Name, Url = game.Url, Type = game.Type } : 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 }); | ||||