Browse Source

Add library-level support for Game presences

pull/877/head
Christopher F Christopher F 8 years ago
parent
commit
4b1c985333
5 changed files with 97 additions and 5 deletions
  1. +33
    -5
      src/Discord.Net.Core/Entities/Users/Game.cs
  2. +18
    -0
      src/Discord.Net.Core/Entities/Users/GameAssets.cs
  3. +14
    -0
      src/Discord.Net.Core/Entities/Users/GameParty.cs
  4. +16
    -0
      src/Discord.Net.Core/Entities/Users/GameSecrets.cs
  5. +16
    -0
      src/Discord.Net.Core/Entities/Users/GameTimestamps.cs

+ 33
- 5
src/Discord.Net.Core/Entities/Users/Game.cs View File

@@ -1,22 +1,50 @@
using System.Diagnostics;
using System;
using System.Diagnostics;


namespace Discord namespace Discord
{ {
// TODO 2.x: make this a class?
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public struct Game public struct Game
{ {
// All
public string Name { get; } public string Name { get; }
public string StreamUrl { get; }
public StreamType StreamType { get; } public StreamType StreamType { get; }
// Streaming
public string StreamUrl { get; }
// Rich
public string Details { get; }
public string State { get; }
public ulong? ApplicationId { get; }
public GameAssets? Assets { get; }
public GameParty? Party { get; }
public GameSecrets? Secrets { get; }
public GameTimestamps? Timestamps { get; }


public Game(string name, string streamUrl, StreamType type)
public Game(string name, string streamUrl = null, StreamType type = StreamType.NotStreaming)
: this(name, streamUrl, type, null, null, null, null, null, null, null) { }
public Game(string name,
string streamUrl,
StreamType type,
string details,
string state,
ulong? applicationId,
GameAssets? assets,
GameParty? party,
GameSecrets? secrets,
GameTimestamps? timestamps)
{ {
Name = name; Name = name;
StreamUrl = streamUrl; StreamUrl = streamUrl;
StreamType = type; StreamType = type;
Details = details;
State = state;
ApplicationId = applicationId;
Assets = assets;
Party = party;
Secrets = secrets;
Timestamps = timestamps;
} }
private Game(string name)
: this(name, null, StreamType.NotStreaming) { }


public override string ToString() => Name; public override string ToString() => Name;
private string DebuggerDisplay => StreamUrl != null ? $"{Name} ({StreamUrl})" : Name; private string DebuggerDisplay => StreamUrl != null ? $"{Name} ({StreamUrl})" : Name;


+ 18
- 0
src/Discord.Net.Core/Entities/Users/GameAssets.cs View File

@@ -0,0 +1,18 @@
namespace Discord
{
public struct GameAssets
{
public string SmallText { get; }
public string SmallImage { get; }
public string LargeText { get; }
public string LargeImage { get; }

public GameAssets(string smallText, string smallImage, string largeText, string largeImage)
{
SmallText = smallText;
SmallImage = smallImage;
LargeText = largeText;
LargeImage = largeImage;
}
}
}

+ 14
- 0
src/Discord.Net.Core/Entities/Users/GameParty.cs View File

@@ -0,0 +1,14 @@
namespace Discord
{
public struct GameParty
{
public ulong[] Size { get; }
public ulong Id { get; }

public GameParty(ulong[] size, ulong id)
{
Size = size;
Id = id;
}
}
}

+ 16
- 0
src/Discord.Net.Core/Entities/Users/GameSecrets.cs View File

@@ -0,0 +1,16 @@
namespace Discord
{
public struct GameSecrets
{
public string Match { get; }
public string Join { get; }
public string Spectate { get; }

public GameSecrets(string match, string join, string spectate)
{
Match = match;
Join = join;
Spectate = spectate;
}
}
}

+ 16
- 0
src/Discord.Net.Core/Entities/Users/GameTimestamps.cs View File

@@ -0,0 +1,16 @@
using System;

namespace Discord
{
public struct GameTimestamps
{
public DateTimeOffset Start { get; }
public DateTimeOffset End { get; }

public GameTimestamps(DateTimeOffset start, DateTimeOffset end)
{
Start = start;
End = end;
}
}
}

Loading…
Cancel
Save