public static void Open() { try { if (!Directory.Exists(Folder)) { Directory.CreateDirectory(Folder); } LiteDatabase = new LiteDatabase(DatabasePath); PlayerCollection = LiteDatabase.GetCollection <Player>(); WarnCollection = LiteDatabase.GetCollection <Warn>(); KickCollection = LiteDatabase.GetCollection <Kick>(); MuteCollection = LiteDatabase.GetCollection <Mute>(); BanCollection = LiteDatabase.GetCollection <Ban>(); SoftBanCollection = LiteDatabase.GetCollection <SoftBan>(); SoftWarnCollection = LiteDatabase.GetCollection <SoftWarn>(); WatchListCollection = LiteDatabase.GetCollection <WatchList>(); PlayerCollection.EnsureIndex(p => p.Id, true); WarnCollection.EnsureIndex(w => w.Target.Id); WarnCollection.EnsureIndex(w => w.Issuer.Id); WarnCollection.EnsureIndex(w => w.Date); KickCollection.EnsureIndex(k => k.Target.Id); KickCollection.EnsureIndex(k => k.Issuer.Id); KickCollection.EnsureIndex(k => k.Date); MuteCollection.EnsureIndex(m => m.Target.Id); MuteCollection.EnsureIndex(m => m.Issuer.Id); MuteCollection.EnsureIndex(m => m.Date); MuteCollection.EnsureIndex(m => m.Expire); BanCollection.EnsureIndex(b => b.Target.Id); BanCollection.EnsureIndex(b => b.Issuer.Id); BanCollection.EnsureIndex(b => b.Date); BanCollection.EnsureIndex(b => b.Expire); SoftBanCollection.EnsureIndex(sb => sb.Target.Id); SoftBanCollection.EnsureIndex(sb => sb.Issuer.Id); SoftBanCollection.EnsureIndex(sb => sb.Date); SoftBanCollection.EnsureIndex(sb => sb.Expire); SoftWarnCollection.EnsureIndex(sw => sw.Target.Id); SoftWarnCollection.EnsureIndex(sw => sw.Issuer.Id); SoftWarnCollection.EnsureIndex(sw => sw.Date); WatchListCollection.EnsureIndex(wl => wl.Target.Id); WatchListCollection.EnsureIndex(wl => wl.Issuer.Id); WatchListCollection.EnsureIndex(wl => wl.Date); Log.Info("Database Loaded!"); } catch (Exception e) { Log.Error($"Error when try to open database:\n {e}"); } }