From b3d6930142c0639587b2c94adc1e9fe5fef96efe Mon Sep 17 00:00:00 2001 From: Andrei Tudor Date: Sun, 30 Jul 2023 22:26:43 +0300 Subject: [PATCH] Updated functions in Discord Bot --- DiscordBot/DiscordBot.csproj | 1 + PluginManager/Config.cs | 11 +++-------- PluginManager/Others/Functions.cs | 6 ++++++ SethDiscordBot.sln | 7 +++++++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/DiscordBot/DiscordBot.csproj b/DiscordBot/DiscordBot.csproj index 9743841..ed95d3b 100644 --- a/DiscordBot/DiscordBot.csproj +++ b/DiscordBot/DiscordBot.csproj @@ -32,6 +32,7 @@ + diff --git a/PluginManager/Config.cs b/PluginManager/Config.cs index fa45d59..a69e4f8 100644 --- a/PluginManager/Config.cs +++ b/PluginManager/Config.cs @@ -51,16 +51,11 @@ public class Config private readonly string _file = ""; private readonly IDictionary? _dictionary; - /// - /// Empty constructor - /// - public Json() - { - _dictionary = new Dictionary(); - } - public Json(string file) { + if (file is null) throw new FileLoadException("The file can not be null"); + if(!File.Exists(file)) + File.Create(file).Close(); _dictionary = PrivateReadConfig(file).GetAwaiter().GetResult(); _file = file; } diff --git a/PluginManager/Others/Functions.cs b/PluginManager/Others/Functions.cs index 5c6ad0c..d8e5f7b 100644 --- a/PluginManager/Others/Functions.cs +++ b/PluginManager/Others/Functions.cs @@ -16,6 +16,7 @@ public static class Functions { /// /// The location for the Resources folder + /// String: ./Data/Resources/ /// public static readonly string dataFolder = @"./Data/Resources/"; @@ -125,4 +126,9 @@ public static class Functions Random random = new(); return values[random.Next(values.Length)]; } + + public static string ToResourcesPath(this string path) + { + return Path.Combine(dataFolder, path); + } } diff --git a/SethDiscordBot.sln b/SethDiscordBot.sln index 2d6941b..9cbf673 100644 --- a/SethDiscordBot.sln +++ b/SethDiscordBot.sln @@ -11,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SethPlugins", "SethPlugins" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LevelingSystem", "SethPlugins\LevelingSystem\LevelingSystem.csproj", "{4D2648BB-B56E-4BE9-B3D5-4D6FA4A1472C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MusicPlayer", "SethPlugins\MusicPlayer\MusicPlayer.csproj", "{AF267C51-AF51-44A7-ACF8-D83A2A90CD53}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -29,12 +31,17 @@ Global {4D2648BB-B56E-4BE9-B3D5-4D6FA4A1472C}.Debug|Any CPU.Build.0 = Debug|Any CPU {4D2648BB-B56E-4BE9-B3D5-4D6FA4A1472C}.Release|Any CPU.ActiveCfg = Release|Any CPU {4D2648BB-B56E-4BE9-B3D5-4D6FA4A1472C}.Release|Any CPU.Build.0 = Release|Any CPU + {AF267C51-AF51-44A7-ACF8-D83A2A90CD53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF267C51-AF51-44A7-ACF8-D83A2A90CD53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF267C51-AF51-44A7-ACF8-D83A2A90CD53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF267C51-AF51-44A7-ACF8-D83A2A90CD53}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {4D2648BB-B56E-4BE9-B3D5-4D6FA4A1472C} = {78B6D390-F61A-453F-B38D-E4C054321615} + {AF267C51-AF51-44A7-ACF8-D83A2A90CD53} = {78B6D390-F61A-453F-B38D-E4C054321615} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3FB3C5DE-ED21-4D2E-ABDD-3A00EE4A2FFF}