Archived
1
0
Fork 0

debug stuff i think

This commit is contained in:
flash 2017-05-19 01:04:45 +02:00
parent ec096e79c4
commit 0c2bab4a94
3 changed files with 23 additions and 12 deletions

View file

@ -21,6 +21,12 @@ namespace Maki
/// </summary> /// </summary>
public class Discord : IDisposable public class Discord : IDisposable
{ {
// temporary, whether gateway data should be written to a file
public bool LogGateway = false;
// temporary, whether rest data should be written to the console
public bool LogRest = false;
/// <summary> /// <summary>
/// Discord Gateway/API version we're targeting /// Discord Gateway/API version we're targeting
/// </summary> /// </summary>
@ -810,16 +816,19 @@ namespace Maki
private void ShardManager_OnSocketMessage(GatewayShard shard, string text) private void ShardManager_OnSocketMessage(GatewayShard shard, string text)
{ {
if (!Directory.Exists("Json")) if (LogGateway)
Directory.CreateDirectory("Json"); {
if (!Directory.Exists("Json"))
Directory.CreateDirectory("Json");
File.WriteAllText( File.WriteAllText(
$"Json/{DateTime.Now:yyyy-MM-dd HH-mm-ss.fffffff}.json", $"Json/{DateTime.Now:yyyy-MM-dd HH-mm-ss.fffffff}.json",
JsonConvert.SerializeObject( JsonConvert.SerializeObject(
JsonConvert.DeserializeObject(text), JsonConvert.DeserializeObject(text),
Formatting.Indented Formatting.Indented
) )
); );
}
} }
#region IDisposable #region IDisposable

View file

@ -15,8 +15,10 @@ namespace Maki
public string Name { get; internal set; } public string Name { get; internal set; }
public ulong OwnerId { get; internal set; } public ulong OwnerId { get; internal set; }
public DiscordMember Owner => Members.Where(x => x.User.Id == OwnerId).FirstOrDefault();
public DiscordMember[] Members => client.members.Where(x => x.Server == this).ToArray(); public DiscordMember[] Members => client.members.Where(x => x.Server == this).ToArray();
public DiscordMember Owner => Members.Where(x => x.User.Id == OwnerId).FirstOrDefault();
public DiscordMember Me => Members.Where(x => x.User == client.Me).FirstOrDefault();
public DiscordRole[] Roles => client.roles.Where(x => x.Server == this).ToArray(); public DiscordRole[] Roles => client.roles.Where(x => x.Server == this).ToArray();
internal DiscordServer(Discord discord, Guild guild) internal DiscordServer(Discord discord, Guild guild)

View file

@ -1,7 +1,6 @@
using Maki.Structures.Rest; using Maki.Structures.Rest;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@ -112,7 +111,8 @@ namespace Maki.Rest
response.ErrorMessage = error.Message; response.ErrorMessage = error.Message;
} }
Console.WriteLine(response.RawResponse); if (client.LogRest)
Console.WriteLine(response.RawResponse);
if (response.Status == 200) if (response.Status == 200)
response.Response = JsonConvert.DeserializeObject<T>(response.RawResponse); response.Response = JsonConvert.DeserializeObject<T>(response.RawResponse);