Class DurationPunishment
- Namespace
- Uncreated.Warfare.Moderation.Punishments
- Assembly
- Uncreated.Warfare.dll
public abstract class DurationPunishment : Punishment, IForgiveableModerationEntry, IDurationModerationEntry, IModerationEntry
- Inheritance
-
DurationPunishment
- Implements
- Derived
- Inherited Members
Properties
Duration
Length of the punishment, negative implies permanent.
[JsonPropertyName("duration")]
public TimeSpan Duration { get; set; }
Property Value
ForgiveMessage
Why the moderation entry was forgiven.
[JsonPropertyName("forgive_message")]
public string? ForgiveMessage { get; set; }
Property Value
ForgiveTimestamp
When the moderation entry was forgiven.
[JsonPropertyName("forgive_timestamp_utc")]
public DateTimeOffset? ForgiveTimestamp { get; set; }
Property Value
Forgiven
If the moderation entry was forgiven.
[JsonPropertyName("is_forgiven")]
public bool Forgiven { get; set; }
Property Value
ForgivenBy
Who forgave the moderation entry.
[JsonPropertyName("forgiving_actor")]
[JsonConverter(typeof(ActorConverter))]
public IModerationActor? ForgivenBy { get; set; }
Property Value
IsPermanent
[JsonIgnore]
public bool IsPermanent { get; set; }
Property Value
Remarks
This is indicated by a negative Duration.
Exceptions
- ArgumentException
Thrown if you set to false.
Methods
AddExtraInfo(DatabaseInterface, List<string>, IFormatProvider, CancellationToken)
public override Task AddExtraInfo(DatabaseInterface db, List<string> workingList, IFormatProvider formatter, CancellationToken token = default)
Parameters
dbDatabaseInterfaceworkingListList<string>formatterIFormatProvidertokenCancellationToken
Returns
GetExpiryTimestamp(bool)
Gets the time at which the punishment expires.
public DateTimeOffset GetExpiryTimestamp(bool considerForgiven)
Parameters
Returns
Exceptions
- InvalidOperationException
This punishment hasn't been resolved (ResolvedTimestamp is null).
GetTimeUntilExpiry(bool)
Gets the length of time until the punishment expires.
public TimeSpan GetTimeUntilExpiry(bool considerForgiven)
Parameters
Returns
Exceptions
- InvalidOperationException
This punishment hasn't been resolved (ResolvedTimestamp is null).
GetTimeUntilExpiryAt(DateTimeOffset, bool)
Gets the length of time until the punishment expires from timestamp.
public TimeSpan GetTimeUntilExpiryAt(DateTimeOffset timestamp, bool considerForgiven)
Parameters
timestampDateTimeOffsetconsiderForgivenbool
Returns
Exceptions
- InvalidOperationException
This punishment hasn't been resolved (ResolvedTimestamp is null).
IsApplied(bool)
Checks if the punishment is still active.
public bool IsApplied(bool considerForgiven)
Parameters
Returns
Exceptions
- InvalidOperationException
This punishment hasn't been resolved (ResolvedTimestamp is null).
ReadProperty(ref Utf8JsonReader, string, JsonSerializerOptions)
public override bool ReadProperty(ref Utf8JsonReader reader, string propertyName, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderpropertyNamestringoptionsJsonSerializerOptions
Returns
WasAppliedAt(DateTimeOffset, bool)
Checks if the punishment was still active at timestamp.
public bool WasAppliedAt(DateTimeOffset timestamp, bool considerForgiven)
Parameters
timestampDateTimeOffsetconsiderForgivenbool
Returns
Exceptions
- InvalidOperationException
This punishment hasn't been resolved (ResolvedTimestamp is null).
Write(Utf8JsonWriter, JsonSerializerOptions)
public override void Write(Utf8JsonWriter writer, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriteroptionsJsonSerializerOptions