2021-10-13 09:29:33 +00:00
|
|
|
using Newtonsoft.Json;
|
2021-09-30 02:30:20 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
2021-10-13 09:29:33 +00:00
|
|
|
using NodaTime;
|
|
|
|
|
2021-09-30 02:30:20 +00:00
|
|
|
using PluralKit.Core;
|
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
namespace PluralKit.API;
|
|
|
|
|
|
|
|
public static class APIJsonExt
|
2021-09-30 02:30:20 +00:00
|
|
|
{
|
2022-03-15 04:09:27 +00:00
|
|
|
public static JObject ToJson(this ModelRepository.Counts counts, int guildCount, int channelCount)
|
2021-10-13 09:29:33 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
var o = new JObject();
|
2021-10-13 09:29:33 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
o.Add("system_count", counts.SystemCount);
|
|
|
|
o.Add("member_count", counts.MemberCount);
|
|
|
|
o.Add("group_count", counts.GroupCount);
|
|
|
|
o.Add("switch_count", counts.SwitchCount);
|
|
|
|
o.Add("message_count", counts.MessageCount);
|
|
|
|
|
2022-03-15 04:09:27 +00:00
|
|
|
// Discord statistics
|
|
|
|
o.Add("guild_count", guildCount);
|
|
|
|
o.Add("channel_count", channelCount);
|
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
return o;
|
2021-10-13 09:29:33 +00:00
|
|
|
}
|
2021-11-27 02:10:56 +00:00
|
|
|
}
|
2021-10-13 09:29:33 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public struct FrontersReturnNew
|
|
|
|
{
|
|
|
|
[JsonProperty("id")] public Guid Uuid { get; set; }
|
|
|
|
[JsonProperty("timestamp")] public Instant Timestamp { get; set; }
|
|
|
|
[JsonProperty("members")] public IEnumerable<JObject> Members { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct SwitchesReturnNew
|
|
|
|
{
|
|
|
|
[JsonProperty("id")] public Guid Uuid { get; set; }
|
|
|
|
[JsonProperty("timestamp")] public Instant Timestamp { get; set; }
|
|
|
|
[JsonProperty("members")] public IEnumerable<string> Members { get; set; }
|
2021-09-30 02:30:20 +00:00
|
|
|
}
|