Browse Source

Implimented the new GameObject for UserPresences

pull/58/head
Khionu Terabite 9 years ago
parent
commit
c3df2577ec
11 changed files with 52 additions and 18 deletions
  1. +2
    -0
      src/Discord.Net.Net45/Discord.Net.csproj
  2. +8
    -0
      src/Discord.Net.Net45/Enums/GameType.cs
  3. +9
    -0
      src/Discord.Net.Net45/Models/Game.cs
  4. +0
    -5
      src/Discord.Net/API/Client/Common/MemberPresence.cs
  5. +0
    -6
      src/Discord.Net/API/Client/GatewaySocket/Commands/UpdateStatus.cs
  6. +11
    -2
      src/Discord.Net/DiscordClient.cs
  7. +8
    -0
      src/Discord.Net/Enums/GameType.cs
  8. +9
    -0
      src/Discord.Net/Models/Game.cs
  9. +1
    -1
      src/Discord.Net/Models/Profile.cs
  10. +2
    -2
      src/Discord.Net/Models/User.cs
  11. +2
    -2
      src/Discord.Net/Net/WebSockets/GatewaySocket.cs

+ 2
- 0
src/Discord.Net.Net45/Discord.Net.csproj View File

@@ -604,6 +604,8 @@
<Compile Include="..\Discord.Net\TaskManager.cs">
<Link>TaskManager.cs</Link>
</Compile>
<Compile Include="Enums\GameType.cs" />
<Compile Include="Models\Game.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>


+ 8
- 0
src/Discord.Net.Net45/Enums/GameType.cs View File

@@ -0,0 +1,8 @@
namespace Discord
{
public enum GameType : int
{
Default = 0, // "NotStreaming", pretty much
Twitch
}
}

+ 9
- 0
src/Discord.Net.Net45/Models/Game.cs View File

@@ -0,0 +1,9 @@
namespace Discord
{
public class GameInfo
{
public string Name { get; set; }
public string Url { get; set; }
public GameType Type { get; set; }
}
}

+ 0
- 5
src/Discord.Net/API/Client/Common/MemberPresence.cs View File

@@ -5,11 +5,6 @@ namespace Discord.API.Client
{
public class MemberPresence : MemberReference
{
public class GameInfo
{
[JsonProperty("name")]
public string Name { get; set; }
}
[JsonProperty("game")]
public GameInfo Game { get; set; }
[JsonProperty("status")]


+ 0
- 6
src/Discord.Net/API/Client/GatewaySocket/Commands/UpdateStatus.cs View File

@@ -9,12 +9,6 @@ namespace Discord.API.Client.GatewaySocket
object IWebSocketMessage.Payload => this;
bool IWebSocketMessage.IsPrivate => false;

public class GameInfo
{
[JsonProperty("name")]
public string Name { get; set; }
}

[JsonProperty("idle_since")]
public long? IdleSince { get; set; }
[JsonProperty("game")]


+ 11
- 2
src/Discord.Net/DiscordClient.cs View File

@@ -65,7 +65,7 @@ namespace Discord
/// <summary> Gets the status of the current user. </summary>
public UserStatus Status { get; private set; }
/// <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>
public IEnumerable<IService> Services => _services;
@@ -316,11 +316,20 @@ namespace Discord
Status = status;
SendStatus();
}
public void SetGame(string game)
public void SetGame(GameInfo game)
{
CurrentGame = game;
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()
{
PrivateUser.Status = Status;


+ 8
- 0
src/Discord.Net/Enums/GameType.cs View File

@@ -0,0 +1,8 @@
namespace Discord
{
public enum GameType : int
{
Default = 0, // "NotStreaming", pretty much
Twitch
}
}

+ 9
- 0
src/Discord.Net/Models/Game.cs View File

@@ -0,0 +1,9 @@
namespace Discord
{
public class GameInfo
{
public string Name { get; set; }
public string Url { get; set; }
public GameType Type { get; set; }
}
}

+ 1
- 1
src/Discord.Net/Models/Profile.cs View File

@@ -23,7 +23,7 @@ namespace Discord
/// <summary> Gets an id uniquely identifying from others with the same name. </summary>
public ushort Discriminator => Client.PrivateUser.Discriminator;
/// <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>
public UserStatus Status => Client.PrivateUser.Status;
/// <summary> Returns the string used to mention this user. </summary>


+ 2
- 2
src/Discord.Net/Models/User.cs View File

@@ -63,7 +63,7 @@ namespace Discord
/// <summary> Gets the unique identifier for this user's current avatar. </summary>
public string AvatarId { get; private set; }
/// <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>
public bool IsBot { get; internal set; }
/// <summary> Gets the current status for this user. </summary>
@@ -208,7 +208,7 @@ namespace Discord
_lastOnline = DateTime.UtcNow;
}
CurrentGame = model.Game?.Name; //Allows null
CurrentGame = model.Game; //Allows null
}
internal void Update(MemberVoiceState model)
{


+ 2
- 2
src/Discord.Net/Net/WebSockets/GatewaySocket.cs View File

@@ -167,11 +167,11 @@ namespace Discord.Net.WebSockets
=> QueueMessage(new ResumeCommand { SessionId = SessionId, Sequence = _lastSequence });
public override void SendHeartbeat()
=> QueueMessage(new HeartbeatCommand());
public void SendUpdateStatus(long? idleSince, string gameName)
public void SendUpdateStatus(long? idleSince, GameInfo game)
=> QueueMessage(new UpdateStatusCommand
{
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)
=> QueueMessage(new UpdateVoiceCommand { GuildId = serverId, ChannelId = channelId, IsSelfMuted = isSelfMuted, IsSelfDeafened = isSelfDeafened });


Loading…
Cancel
Save