From 0e997f4b35b053b16d9552ab6c7545deadb6756d Mon Sep 17 00:00:00 2001 From: AnalogFeelings <51166756+AnalogFeelings@users.noreply.github.com> Date: Sun, 14 Apr 2024 18:58:50 +0200 Subject: [PATCH] [Bot -> Settings] Remove data directory constant. --- Source/SammBot.Bot/Database/BotDatabase.cs | 4 ++-- Source/SammBot.Bot/EntryPoint.cs | 2 +- Source/SammBot.Bot/SammBot.Bot.csproj | 4 ++-- Source/SammBot.Bot/Settings/SettingsManager.cs | 13 ++----------- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Source/SammBot.Bot/Database/BotDatabase.cs b/Source/SammBot.Bot/Database/BotDatabase.cs index 53478f4..66e5532 100644 --- a/Source/SammBot.Bot/Database/BotDatabase.cs +++ b/Source/SammBot.Bot/Database/BotDatabase.cs @@ -19,9 +19,9 @@ using JetBrains.Annotations; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; -using SammBot.Bot.Settings; using SammBot.Library.Models.Database; using System.IO; +using SammBot.Library; namespace SammBot.Bot.Database; @@ -46,7 +46,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - string databaseFile = Path.Combine(SettingsManager.Instance.BotDataDirectory, "bot.db"); + string databaseFile = Path.Combine(Constants.BotDataDirectory, "bot.db"); SqliteConnectionStringBuilder connectionStringBuilder = new SqliteConnectionStringBuilder() { DataSource = databaseFile }; SqliteConnection connection = new SqliteConnection(connectionStringBuilder.ToString()); diff --git a/Source/SammBot.Bot/EntryPoint.cs b/Source/SammBot.Bot/EntryPoint.cs index 259303c..19e62cd 100644 --- a/Source/SammBot.Bot/EntryPoint.cs +++ b/Source/SammBot.Bot/EntryPoint.cs @@ -169,7 +169,7 @@ private MatchaLogger InitializeLogger() FileSinkConfig fileConfig = new FileSinkConfig() { SeverityFilterLevel = filterLevel, - FilePath = Path.Combine(SettingsManager.Instance.BotDataDirectory, "Logs") + FilePath = Path.Combine(Constants.BotDataDirectory, "Logs") }; ConsoleSink consoleSink = new ConsoleSink() diff --git a/Source/SammBot.Bot/SammBot.Bot.csproj b/Source/SammBot.Bot/SammBot.Bot.csproj index 4d636e6..53bba81 100644 --- a/Source/SammBot.Bot/SammBot.Bot.csproj +++ b/Source/SammBot.Bot/SammBot.Bot.csproj @@ -6,8 +6,8 @@ en Analog Feelings Samm-Bot - 8.0 - 8.0 + 9.0 + 9.0 12 enable diff --git a/Source/SammBot.Bot/Settings/SettingsManager.cs b/Source/SammBot.Bot/Settings/SettingsManager.cs index 05d7bdd..0271fe4 100644 --- a/Source/SammBot.Bot/Settings/SettingsManager.cs +++ b/Source/SammBot.Bot/Settings/SettingsManager.cs @@ -28,22 +28,13 @@ public class SettingsManager { public BotConfig LoadedConfig = new BotConfig(); - public readonly string BotDataDirectory; - - private SettingsManager() - { - string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - - BotDataDirectory = Path.Combine(appData, Constants.BOT_NAME); - } - public bool LoadConfiguration() { - string configFilePath = Path.Combine(BotDataDirectory, Constants.CONFIG_FILE); + string configFilePath = Path.Combine(Constants.BotDataDirectory, Constants.CONFIG_FILE); try { - Directory.CreateDirectory(BotDataDirectory); + Directory.CreateDirectory(Constants.BotDataDirectory); if (!File.Exists(configFilePath)) return false; }