debug stuff i think
This commit is contained in:
parent
ec096e79c4
commit
0c2bab4a94
3 changed files with 23 additions and 12 deletions
|
@ -21,6 +21,12 @@ namespace Maki
|
|||
/// </summary>
|
||||
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>
|
||||
/// Discord Gateway/API version we're targeting
|
||||
/// </summary>
|
||||
|
@ -810,16 +816,19 @@ namespace Maki
|
|||
|
||||
private void ShardManager_OnSocketMessage(GatewayShard shard, string text)
|
||||
{
|
||||
if (!Directory.Exists("Json"))
|
||||
Directory.CreateDirectory("Json");
|
||||
if (LogGateway)
|
||||
{
|
||||
if (!Directory.Exists("Json"))
|
||||
Directory.CreateDirectory("Json");
|
||||
|
||||
File.WriteAllText(
|
||||
$"Json/{DateTime.Now:yyyy-MM-dd HH-mm-ss.fffffff}.json",
|
||||
JsonConvert.SerializeObject(
|
||||
JsonConvert.DeserializeObject(text),
|
||||
Formatting.Indented
|
||||
)
|
||||
);
|
||||
File.WriteAllText(
|
||||
$"Json/{DateTime.Now:yyyy-MM-dd HH-mm-ss.fffffff}.json",
|
||||
JsonConvert.SerializeObject(
|
||||
JsonConvert.DeserializeObject(text),
|
||||
Formatting.Indented
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
|
|
@ -15,8 +15,10 @@ namespace Maki
|
|||
public string Name { 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 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();
|
||||
|
||||
internal DiscordServer(Discord discord, Guild guild)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using Maki.Structures.Rest;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
@ -112,7 +111,8 @@ namespace Maki.Rest
|
|||
response.ErrorMessage = error.Message;
|
||||
}
|
||||
|
||||
Console.WriteLine(response.RawResponse);
|
||||
if (client.LogRest)
|
||||
Console.WriteLine(response.RawResponse);
|
||||
|
||||
if (response.Status == 200)
|
||||
response.Response = JsonConvert.DeserializeObject<T>(response.RawResponse);
|
||||
|
|
Reference in a new issue