public bool FromJSON(JSONContainer json) { if (json.TryGetField(JSON_MODTYPE, out uint type) && json.TryGetField(JSON_CHANNELID, out ulong channelId) && json.TryGetField(JSON_ACTORID, out ulong actorid)) { Type = (ChannelModerationType)type; ChannelId = channelId; ActorId = actorid; if (json.TryGetField(JSON_TIMESTAMP, out string timestamp_str)) { if (DateTimeOffset.TryParseExact(timestamp_str, "u", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTimeOffset timestamp)) { Timestamp = timestamp; } else { Timestamp = DateTimeOffset.MinValue; } } json.TryGetField(JSON_CHANNELNAME, out string channelname); ChannelName = channelname; json.TryGetField(JSON_ACTORNAME, out string actorname); ActorName = actorname; json.TryGetField(JSON_INFO, out string info); Info = info; return(true); } return(false); }
public ChannelModerationEntry(ulong guildId, ChannelModerationType type, SocketGuildChannel channel, SocketGuildUser actor, string info = null) { GuildId = guildId; Type = type; Timestamp = DateTimeOffset.UtcNow; ChannelId = channel.Id; ChannelName = channel.Name; ActorId = actor.Id; ActorName = actor.ToString(); Info = info; }