Added garbage to attempt to update json field name.

This commit is contained in:
TheUbMunster 2023-06-27 21:34:17 -06:00
parent fc70cb90d8
commit 67a00716f8
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using Newtonsoft;
namespace Server.LegacyJsonSupport
{
public class LogToAdminJsonConverter : JsonConverter<string>
{
public override string? ReadJson(JsonReader reader, Type objectType, string? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
//JToken t = JToken.Load(reader);
if (reader.TokenType != JsonToken.String)
return null;
//JObject j = JObject.Load(reader);
//string? k = reader.ReadAsString();
//if (k == "LogChannel" || k == "AdminChannel")
return hasExistingValue ? existingValue : (string?)reader.Value;
//else
// return null;
}
public override void WriteJson(JsonWriter writer, string? value, JsonSerializer serializer)
{
//writer.
//writer.WritePropertyName("AdminChannel");
writer.WriteValue(value);
}
}
}

View File

@ -3,6 +3,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using Shared;
using Server.LegacyJsonSupport;
namespace Server;
@ -74,7 +75,8 @@ public class Settings {
public string? Token { get; set; }
public string Prefix { get; set; } = "$";
public string? CommandChannel { get; set; }
[JsonProperty(PropertyName = "LogChannel")]
[JsonProperty(PropertyName = "AdminChannel")]
[JsonConverter(typeof(LogToAdminJsonConverter))]
public string? AdminChannel { get; set; }
public bool LogCommands { get; set; } = false;
public bool FilterOutNonIssueWarnings { get; set; } = true;