private static ActiveTimedEvent BuildActiveTimedEvent(UserDisciplinaryEventStorage eventStorage) { var activeEvent = new ActiveTimedEvent(); activeEvent.DisciplinaryEvent = eventStorage.DiscipinaryEventType; activeEvent.TimeToTrigger = eventStorage.DateToRemove.Subtract(eventStorage.DateInserted).TotalMinutes; activeEvent.UserId = eventStorage.UserID; return(activeEvent); }
private static async Task HandleEventElapsed(ActiveTimedEvent activeEvent) { try { switch (activeEvent.DisciplinaryEvent) { case DisciplinaryEventEnum.MuteEvent: ActiveEvents.Remove(activeEvent); await DiscordContextSeymour.RemoveRoleAsync(activeEvent.UserId, ConfigManager.GetUlongProperty(PropertyItem.Role_Muted)); await DiscordContextOverseer.LogModerationAction(activeEvent.UserId, "Unmuted", activeEvent.Reason, ""); await StorageManager.ArchiveTimedEventAsync(activeEvent.DisciplinaryEventId); break; case DisciplinaryEventEnum.WarnEvent: ActiveEvents.Remove(activeEvent); await StorageManager.ArchiveTimedEventAsync(activeEvent.DisciplinaryEventId); break; case DisciplinaryEventEnum.LimitedUserEvent: ActiveEvents.Remove(activeEvent); await DiscordContextSeymour.RemoveRoleAsync(activeEvent.UserId, ConfigManager.GetUlongProperty(PropertyItem.Role_LimitedUser)); await DiscordContextOverseer.LogModerationAction(activeEvent.UserId, "Unlimited", activeEvent.Reason, ""); await StorageManager.ArchiveTimedEventAsync(activeEvent.DisciplinaryEventId); break; case DisciplinaryEventEnum.RestrictedUserEvent: ActiveEvents.Remove(activeEvent); await DiscordContextSeymour.RemoveRoleAsync(activeEvent.UserId, ConfigManager.GetUlongProperty(PropertyItem.Role_Restricted)); await DiscordContextOverseer.LogModerationAction(activeEvent.UserId, "Unrestricted", activeEvent.Reason, ""); await StorageManager.ArchiveTimedEventAsync(activeEvent.DisciplinaryEventId); break; default: ActiveEvents.Remove(activeEvent); await DiscordContextOverseer.LogModerationAction(activeEvent.UserId, $"Err : {activeEvent.DisciplinaryEvent.ToString()}", activeEvent.Reason, ""); break; } } catch (Exception ex) { await ExceptionManager.LogExceptionAsync(ex); } }