/// <returns>The old reason</returns> public string ChangeInfractionReason(uint id, string newReason) { var infraction = Infractions.Find(x => x.Id == id); var oldReason = infraction.Reason; infraction.Reason = newReason; return(oldReason); }
/// <returns>The old warning</returns> public Infraction RemoveWarningById(uint id) { var infraction = Infractions.Find(x => x.Id == id); if (infraction.Type != InfractionType.Warning) { throw new Exception($"Case {id} is not a warning!"); } Infractions.Remove(infraction); return(infraction); }
public TimeSpan UpdateInfractionDuration(uint id, TimeSpan newTime) { var infraction = Infractions.Find(x => x.Id == id); if (infraction.Type != InfractionType.Ban && infraction.Type != InfractionType.Mute) { throw new Exception($"You can only change the duration on a ban or a mute."); } else if (infraction.FinishesAt < DateTime.UtcNow) { throw new Exception($"You cannot edit a mute/ban that has already finished."); } var oldTime = (infraction.FinishesAt - DateTime.UtcNow).Value; infraction.FinishesAt = DateTime.UtcNow.Add(newTime); return(oldTime); }