Example #1
0
        /// <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);
        }
Example #2
0
        /// <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);
        }
Example #3
0
        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);
        }