Feature: CustomStatusGame Activity (#1406)

* Implement CustomStatusGame activity

Adds the CustomStatusGame class, which is the activity corresponding to the custom status feature.

* Remove unused import from Game.cs
This commit is contained in:
Chris Johnston
2019-11-09 10:41:10 -08:00
committed by Christopher F
parent 5439cbad5a
commit 79a0ea9de3
5 changed files with 73 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
using Discord.Rest;
using System;
using System.Collections.Immutable;
using System.Linq;
@@ -7,6 +9,19 @@ namespace Discord.WebSocket
{
public static IActivity ToEntity(this API.Game model)
{
// Custom Status Game
if (model.Id.IsSpecified)
{
return new CustomStatusGame()
{
Type = ActivityType.CustomStatus,
Name = model.Name,
State = model.State.IsSpecified ? model.State.Value : null,
Emote = model.Emoji.IsSpecified ? model.Emoji.Value.ToIEmote() : null,
CreatedAt = DateTimeOffset.FromUnixTimeMilliseconds(model.CreatedAt.Value),
};
}
// Spotify Game
if (model.SyncId.IsSpecified)
{