Refactor Games, support reading Rich Presences (#877)
* Add API-level support for Rich Presences * Add library-level support for Game presences * Add model conversions for outgoing+incoming rich presences * Refactored Game into Activities * Integrated Activities with user entities rebase hell from 5f3cb947a92f4fd01cc4df47ca548180036b47f3 * Fix JSON converters for Activities * Finish rebase, activity should be set on BaseSocketClient * Use ApplicationId to define a rich presence * Added SetActivityAsync to Base and Sharded Socket clients * Remove public parameterless Game constructor * Remove GameAssets, refactored to GameAsset * Hide constructors for types that should be read-only * Revert changes to Discord.Net.sln got damned visual studio caching * Refactor GameParty to use dedicated current/capacity values Per feedback from @khionu
This commit is contained in:
@@ -13,6 +13,22 @@ namespace Discord.API
|
||||
public Optional<string> StreamUrl { get; set; }
|
||||
[JsonProperty("type")]
|
||||
public Optional<StreamType?> StreamType { get; set; }
|
||||
[JsonProperty("details")]
|
||||
public Optional<string> Details { get; set; }
|
||||
[JsonProperty("state")]
|
||||
public Optional<string> State { get; set; }
|
||||
[JsonProperty("application_id")]
|
||||
public Optional<ulong> ApplicationId { get; set; }
|
||||
[JsonProperty("assets")]
|
||||
public Optional<API.GameAssets> Assets { get; set; }
|
||||
[JsonProperty("party")]
|
||||
public Optional<API.GameParty> Party { get; set; }
|
||||
[JsonProperty("secrets")]
|
||||
public Optional<API.GameSecrets> Secrets { get; set; }
|
||||
[JsonProperty("timestamps")]
|
||||
public Optional<API.GameTimestamps> Timestamps { get; set; }
|
||||
[JsonProperty("instance")]
|
||||
public Optional<bool> Instance { get; set; }
|
||||
|
||||
[OnError]
|
||||
internal void OnError(StreamingContext context, ErrorContext errorContext)
|
||||
|
||||
16
src/Discord.Net.Rest/API/Common/GameAssets.cs
Normal file
16
src/Discord.Net.Rest/API/Common/GameAssets.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
internal class GameAssets
|
||||
{
|
||||
[JsonProperty("small_text")]
|
||||
public Optional<string> SmallText { get; set; }
|
||||
[JsonProperty("small_image")]
|
||||
public Optional<string> SmallImage { get; set; }
|
||||
[JsonProperty("large_image")]
|
||||
public Optional<string> LargeText { get; set; }
|
||||
[JsonProperty("large_text")]
|
||||
public Optional<string> LargeImage { get; set; }
|
||||
}
|
||||
}
|
||||
12
src/Discord.Net.Rest/API/Common/GameParty.cs
Normal file
12
src/Discord.Net.Rest/API/Common/GameParty.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
internal class GameParty
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
[JsonProperty("size")]
|
||||
public int[] Size { get; set; }
|
||||
}
|
||||
}
|
||||
14
src/Discord.Net.Rest/API/Common/GameSecrets.cs
Normal file
14
src/Discord.Net.Rest/API/Common/GameSecrets.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
internal class GameSecrets
|
||||
{
|
||||
[JsonProperty("match")]
|
||||
public string Match { get; set; }
|
||||
[JsonProperty("join")]
|
||||
public string Join { get; set; }
|
||||
[JsonProperty("spectate")]
|
||||
public string Spectate { get; set; }
|
||||
}
|
||||
}
|
||||
15
src/Discord.Net.Rest/API/Common/GameTimestamps.cs
Normal file
15
src/Discord.Net.Rest/API/Common/GameTimestamps.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
internal class GameTimestamps
|
||||
{
|
||||
[JsonProperty("start")]
|
||||
[UnixTimestamp]
|
||||
public Optional<DateTimeOffset> Start { get; set; }
|
||||
[JsonProperty("end")]
|
||||
[UnixTimestamp]
|
||||
public Optional<DateTimeOffset> End { get; set; }
|
||||
}
|
||||
}
|
||||
7
src/Discord.Net.Rest/API/UnixTimestampAttribute.cs
Normal file
7
src/Discord.Net.Rest/API/UnixTimestampAttribute.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
internal class UnixTimestampAttribute : Attribute { }
|
||||
}
|
||||
Reference in New Issue
Block a user