Receiving following error:
[2023-04-17 18:26:21 -04:00] [104 /EventHandler] [Error] Event handler exception for event MESSAGE_CREATED thrown from System.Threading.Tasks.Task <Main>b__3_0(DSharpPlus.DiscordClient, DSharpPlus.EventArgs.MessageCreateEventArgs) (defined in AuctionHouseDiscord.Program+<>c)
System.Text.Json.JsonException: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles. Path: $.User.Presence.User.Presence.User.Presence.User.Presence.User.Presence.User.Presence.User.Presence.User.Presence...(you get the idea)
at System.Text.Json.ThrowHelper.ThrowJsonException_SerializerCycleDetected(Int32 maxDepth)
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
happened as i was deserlising a json of the following class:
public class Player
{
public int Age { get; set; }
public DiscordUser User { get; set; }
public List<ItemQuantity> Inventory { get; set; } = new();
}
public class ItemQuantity
{
public int Quantity { get; set; }
public int ItemID { get; set; }
}