Table of Contents

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

TimeSpan

ForgiveMessage

Why the moderation entry was forgiven.

[JsonPropertyName("forgive_message")]
public string? ForgiveMessage { get; set; }

Property Value

string

ForgiveTimestamp

When the moderation entry was forgiven.

[JsonPropertyName("forgive_timestamp_utc")]
public DateTimeOffset? ForgiveTimestamp { get; set; }

Property Value

DateTimeOffset?

Forgiven

If the moderation entry was forgiven.

[JsonPropertyName("is_forgiven")]
public bool Forgiven { get; set; }

Property Value

bool

ForgivenBy

Who forgave the moderation entry.

[JsonPropertyName("forgiving_actor")]
[JsonConverter(typeof(ActorConverter))]
public IModerationActor? ForgivenBy { get; set; }

Property Value

IModerationActor

IsPermanent

Returns true if the punishment will never expire, not considering Forgiven.

[JsonIgnore]
public bool IsPermanent { get; set; }

Property Value

bool

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

db DatabaseInterface
workingList List<string>
formatter IFormatProvider
token CancellationToken

Returns

Task

GetExpiryTimestamp(bool)

Gets the time at which the punishment expires.

public DateTimeOffset GetExpiryTimestamp(bool considerForgiven)

Parameters

considerForgiven bool

Considers the values of Forgiven and Removed.

Returns

DateTimeOffset

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

considerForgiven bool

Considers the values of Forgiven and Removed.

Returns

TimeSpan

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

timestamp DateTimeOffset
considerForgiven bool

Considers the values of Forgiven and Removed.

Returns

TimeSpan

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

considerForgiven bool

Considers the values of Forgiven and Removed.

Returns

bool

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

reader Utf8JsonReader
propertyName string
options JsonSerializerOptions

Returns

bool

WasAppliedAt(DateTimeOffset, bool)

Checks if the punishment was still active at timestamp.

public bool WasAppliedAt(DateTimeOffset timestamp, bool considerForgiven)

Parameters

timestamp DateTimeOffset
considerForgiven bool

Considers the values of Forgiven and Removed.

Returns

bool

Exceptions

InvalidOperationException

This punishment hasn't been resolved (ResolvedTimestamp is null).

Write(Utf8JsonWriter, JsonSerializerOptions)

public override void Write(Utf8JsonWriter writer, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter
options JsonSerializerOptions