@@ -22,6 +22,12 @@ namespace Discord | |||||
public static string GetEmojiUrl(ulong emojiId) | public static string GetEmojiUrl(ulong emojiId) | ||||
=> $"{DiscordConfig.CDNUrl}emojis/{emojiId}.png"; | => $"{DiscordConfig.CDNUrl}emojis/{emojiId}.png"; | ||||
public static string GetRichAssetUrl(ulong appId, string assetId, ushort size, ImageFormat format) | |||||
{ | |||||
string extension = FormatToExtension(format, ""); | |||||
return $"{DiscordConfig.CDNUrl}app-assets/{appId}/{assetId}.{extension}?size={size}"; | |||||
} | |||||
private static string FormatToExtension(ImageFormat format, string imageId) | private static string FormatToExtension(ImageFormat format, string imageId) | ||||
{ | { | ||||
if (format == ImageFormat.Auto) | if (format == ImageFormat.Auto) | ||||
@@ -0,0 +1,19 @@ | |||||
using System.Diagnostics; | |||||
namespace Discord | |||||
{ | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||||
public class Game : IActivity | |||||
{ | |||||
public string Name { get; internal set; } | |||||
public Game() { } | |||||
public Game(string name) | |||||
{ | |||||
Name = name; | |||||
} | |||||
public override string ToString() => Name; | |||||
private string DebuggerDisplay => Name; | |||||
} | |||||
} |
@@ -0,0 +1,21 @@ | |||||
namespace Discord | |||||
{ | |||||
public class GameAssets | |||||
{ | |||||
public GameAsset Small { get; internal set; } | |||||
public GameAsset Large { get; internal set; } | |||||
} | |||||
public class GameAsset | |||||
{ | |||||
internal GameAsset() { } | |||||
internal ulong ApplicationId { get; set; } | |||||
public string Text { get; internal set; } | |||||
public string ImageId { get; internal set; } | |||||
public string GetImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | |||||
=> CDN.GetRichAssetUrl(ApplicationId, ImageId, size, format); | |||||
} | |||||
} |
@@ -0,0 +1,8 @@ | |||||
namespace Discord | |||||
{ | |||||
public class GameParty | |||||
{ | |||||
public ulong[] Size { get; internal set; } | |||||
public ulong Id { get; internal set; } | |||||
} | |||||
} |
@@ -0,0 +1,13 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Discord | |||||
{ | |||||
public interface IActivity | |||||
{ | |||||
string Name { get; } | |||||
} | |||||
} |
@@ -0,0 +1,19 @@ | |||||
using System.Diagnostics; | |||||
namespace Discord | |||||
{ | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||||
public class RichGame : Game | |||||
{ | |||||
public string Details { get; internal set;} | |||||
public string State { get; internal set;} | |||||
public ulong? ApplicationId { get; internal set; } | |||||
public GameAssets Assets { get; internal set; } | |||||
public GameParty Party { get; internal set; } | |||||
public GameSecrets Secrets { get; internal set; } | |||||
public GameTimestamps Timestamps { get; internal set; } | |||||
public override string ToString() => Name; | |||||
private string DebuggerDisplay => $"{Name} (Rich)"; | |||||
} | |||||
} |
@@ -0,0 +1,21 @@ | |||||
using System.Diagnostics; | |||||
namespace Discord | |||||
{ | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||||
public class StreamingGame : Game | |||||
{ | |||||
public string Url { get; internal set; } | |||||
public StreamType StreamType { get; internal set; } | |||||
public StreamingGame(string name, string url, StreamType streamType) | |||||
{ | |||||
Name = name; | |||||
Url = url; | |||||
StreamType = streamType; | |||||
} | |||||
public override string ToString() => Name; | |||||
private string DebuggerDisplay => $"{Name} ({Url})"; | |||||
} | |||||
} |
@@ -1,52 +0,0 @@ | |||||
using System; | |||||
using System.Diagnostics; | |||||
namespace Discord | |||||
{ | |||||
// TODO 2.x: make this a class? | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||||
public struct Game | |||||
{ | |||||
// All | |||||
public string Name { 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 = 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; | |||||
StreamUrl = streamUrl; | |||||
StreamType = type; | |||||
Details = details; | |||||
State = state; | |||||
ApplicationId = applicationId; | |||||
Assets = assets; | |||||
Party = party; | |||||
Secrets = secrets; | |||||
Timestamps = timestamps; | |||||
} | |||||
public override string ToString() => Name; | |||||
private string DebuggerDisplay => StreamUrl != null ? $"{Name} ({StreamUrl})" : Name; | |||||
} | |||||
} |
@@ -1,18 +0,0 @@ | |||||
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; | |||||
} | |||||
} | |||||
} |
@@ -1,14 +0,0 @@ | |||||
namespace Discord | |||||
{ | |||||
public struct GameParty | |||||
{ | |||||
public ulong[] Size { get; } | |||||
public ulong Id { get; } | |||||
public GameParty(ulong[] size, ulong id) | |||||
{ | |||||
Size = size; | |||||
Id = id; | |||||
} | |||||
} | |||||
} |