diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Data/CloudTheWolf.DSharpPlus.Scaffolding.Data.csproj b/CloudTheWolf.DSharpPlus.Scaffolding.Data/CloudTheWolf.DSharpPlus.Scaffolding.Data.csproj index 3613015..db279c9 100644 --- a/CloudTheWolf.DSharpPlus.Scaffolding.Data/CloudTheWolf.DSharpPlus.Scaffolding.Data.csproj +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Data/CloudTheWolf.DSharpPlus.Scaffolding.Data.csproj @@ -9,9 +9,12 @@ © 2021 CloudTheWolf Ltd Database System for CloudTheWolf.DSharpPlus.Scaffolding Apache-2.0 - 1.0.0.0 + 1.0.0.1 $(AssemblyVersion) - $(AssemblyVersion)-beta + $(AssemblyVersion) + true + logo.png + @@ -20,4 +23,15 @@ + + + True + + + + + + C:\Users\CloudTheWolf\source\repos\CloudTheWolf.DSharpPlus.Scaffolding\CloudTheWolf.DSharpPlus.Scaffolding.Worker\bin\Debug\net5.0\Plugins + + diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Data/MySqlDataAccess.cs b/CloudTheWolf.DSharpPlus.Scaffolding.Data/MySqlDataAccess.cs index 6de1de4..50263d2 100644 --- a/CloudTheWolf.DSharpPlus.Scaffolding.Data/MySqlDataAccess.cs +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Data/MySqlDataAccess.cs @@ -7,13 +7,12 @@ namespace CloudTheWolf.DSharpPlus.Scaffolding.Data { public class MySqlDataAccess : DataAccess { - private string _sqlConnectionString; private MySqlConnection _sqlConnection; public override string LoadConnectionString(string connStr) { - _sqlConnectionString = connStr; - return _sqlConnectionString; + _sqlConnection = new MySqlConnection(connStr); + return _sqlConnection.ConnectionString; } public override string Request(string sqlCommandString) @@ -37,7 +36,6 @@ public override string Request(string sqlCommandString) private void DbConnect() { - _sqlConnection.ConnectionString = _sqlConnectionString; try { _sqlConnection.Open(); diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Data/Properties/launchSettings.json b/CloudTheWolf.DSharpPlus.Scaffolding.Data/Properties/launchSettings.json new file mode 100644 index 0000000..41933d0 --- /dev/null +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Data/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "CloudTheWolf.DSharpPlus.Scaffolding.Data": { + "commandName": "Executable", + "executablePath": "C:\\Users\\CloudTheWolf\\source\\repos\\CloudTheWolf.DSharpPlus.Scaffolding\\CloudTheWolf.DSharpPlus.Scaffolding.Worker\\bin\\Debug\\net5.0\\CloudTheWolf.DSharpPlus.Scaffolding.Worker.exe", + "workingDirectory": "C:\\Users\\CloudTheWolf\\source\\repos\\CloudTheWolf.DSharpPlus.Scaffolding\\CloudTheWolf.DSharpPlus.Scaffolding.Worker\\bin\\Debug\\net5.0", + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Classes/Database.cs b/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Classes/Database.cs new file mode 100644 index 0000000..c2b70e3 --- /dev/null +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Classes/Database.cs @@ -0,0 +1,36 @@ +using CloudTheWolf.DSharpPlus.Scaffolding.Data; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloudTheWolf.DSharpPlus.Scaffolding.Example.Module.Classes +{ + class Database { + + private DataAccess sda; + + internal Database() + { + var MySql = true; + sda = MySql ? new MySqlDataAccess() : new SqlSvrDataAccess(); + + sda.LoadConnectionString($"Server={Options.MySqlHost};Port={Options.MySqlPort};Uid={Options.MySqlUsername};Pwd={Options.MySqlPassword};Database={Options.MySqlDatabase};"); + + } + + + internal JArray GetConfig() + { + + var json = sda.Request("SELECT * FROM config;"); + return JArray.Parse(json); + } + + + + + } +} diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module.csproj b/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module.csproj index 6d75229..0c04911 100644 --- a/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module.csproj +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module.csproj @@ -1,4 +1,4 @@ - + net5.0 @@ -7,11 +7,8 @@ - - - - - + + diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Commands/ExampleCommands.cs b/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Commands/ExampleCommands.cs new file mode 100644 index 0000000..ff254aa --- /dev/null +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Commands/ExampleCommands.cs @@ -0,0 +1,26 @@ +using CloudTheWolf.DSharpPlus.Scaffolding.Example.Module.Classes; +using DSharpPlus.CommandsNext; +using DSharpPlus.CommandsNext.Attributes; +using DSharpPlus.Entities; +using Newtonsoft.Json.Linq; +using System.Threading.Tasks; + +namespace CloudTheWolf.DSharpPlus.Scaffolding.Example.Module.Commands +{ + class ExampleCommands : BaseCommandModule + { + + private Database _dba = new Database(); + + [Command("configs")] + public async Task GetConfigSettings(CommandContext ctx) + { + var exampleArray = _dba.GetConfig(); + foreach(JObject jObject in exampleArray ) + { + await ctx.Channel.SendMessageAsync($"Setting {jObject["name"]} [bValue = {jObject["bValue"]}, iValue = {jObject["iValue"]}]"); + }; + } + + } +} diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Example.cs b/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Example.cs index 1cbf4b6..dd5e43c 100644 --- a/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Example.cs +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Example.cs @@ -1,4 +1,5 @@ -using CloudTheWolf.DSharpPlus.Scaffolding.Logging; +using CloudTheWolf.DSharpPlus.Scaffolding.Example.Module.Commands; +using CloudTheWolf.DSharpPlus.Scaffolding.Logging; using CloudTheWolf.DSharpPlus.Scaffolding.Shared.Interfaces; using DSharpPlus; using Microsoft.Extensions.Configuration; @@ -9,7 +10,7 @@ namespace CloudTheWolf.DSharpPlus.Scaffolding.Example.Module { public class Example : IPlugin { - public string Name => "Example"; + public string Name => "Example Plugin"; public string Description => "An Example Plugin to demo the system"; @@ -20,8 +21,28 @@ public class Example : IPlugin public void InitPlugin(IBot bot, ILogger logger, DiscordConfiguration discordConfiguration, IConfigurationRoot applicationConfig) { Logger = logger; + LoadConfig(applicationConfig); + RegisterCommands(bot); Console.WriteLine("Hello World"); - //Console.WriteLine(applicationConfig.Get("a:b")); + + } + + private void RegisterCommands(IBot bot) + { + + bot.Commands.RegisterCommands(); + Logger.LogInformation($"{Name}: Registared {nameof(ExampleCommands)}!"); + } + + private void LoadConfig(IConfigurationRoot applicationConfig) + { + Options.MySqlHost = applicationConfig.GetValue("SQL:Host"); + Options.MySqlPort = applicationConfig.GetValue("SQL:Port"); + Options.MySqlUsername = applicationConfig.GetValue("SQL:Username"); + Options.MySqlPassword = applicationConfig.GetValue("SQL:Password"); + Options.MySqlDatabase = applicationConfig.GetValue("SQL:Database"); + } + } } diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Options.cs b/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Options.cs new file mode 100644 index 0000000..a770055 --- /dev/null +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Example.Module/Options.cs @@ -0,0 +1,19 @@ +using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloudTheWolf.DSharpPlus.Scaffolding.Example.Module +{ + public class Options + { + public static string MySqlHost { get; set; } + public static int MySqlPort { get; set; } + public static string MySqlUsername { get; set; } + public static string MySqlPassword { get; set; } + public static string MySqlDatabase { get; set; } + + } +} diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Logging/CloudTheWolf.DSharpPlus.Scaffolding.Logging.csproj b/CloudTheWolf.DSharpPlus.Scaffolding.Logging/CloudTheWolf.DSharpPlus.Scaffolding.Logging.csproj index 3cf7fe6..8ced010 100644 --- a/CloudTheWolf.DSharpPlus.Scaffolding.Logging/CloudTheWolf.DSharpPlus.Scaffolding.Logging.csproj +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Logging/CloudTheWolf.DSharpPlus.Scaffolding.Logging.csproj @@ -10,9 +10,12 @@ © 2021 CloudTheWolf Ltd Logger for CloudTheWolf.DSharpPlus.Scaffolding Apache-2.0 - 1.0.0.1 + 1.0.0.3 $(AssemblyVersion) $(AssemblyVersion) + true + logo.png + @@ -24,5 +27,9 @@ PreserveNewest + + True + + diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Shared/CloudTheWolf.DSharpPlus.Scaffolding.Shared.csproj b/CloudTheWolf.DSharpPlus.Scaffolding.Shared/CloudTheWolf.DSharpPlus.Scaffolding.Shared.csproj index 51215df..24bc32b 100644 --- a/CloudTheWolf.DSharpPlus.Scaffolding.Shared/CloudTheWolf.DSharpPlus.Scaffolding.Shared.csproj +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Shared/CloudTheWolf.DSharpPlus.Scaffolding.Shared.csproj @@ -10,20 +10,30 @@ © 2021 CloudTheWolf Ltd Shared Interfaces for CloudTheWolf.DSharpPlus.Scaffolding Apache-2.0 - 1.0.0.3 + 1.0.0.4 $(AssemblyVersion) $(AssemblyVersion)-beta + logo.png + + true - - - - - - - + + + + + + + + + + True + + + + diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Worker/CloudTheWolf.DSharpPlus.Scaffolding.Worker.csproj b/CloudTheWolf.DSharpPlus.Scaffolding.Worker/CloudTheWolf.DSharpPlus.Scaffolding.Worker.csproj index c910a9a..8839e20 100644 --- a/CloudTheWolf.DSharpPlus.Scaffolding.Worker/CloudTheWolf.DSharpPlus.Scaffolding.Worker.csproj +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Worker/CloudTheWolf.DSharpPlus.Scaffolding.Worker.csproj @@ -6,17 +6,24 @@ + + + + + + Never + + + + + + - - - - - diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Worker/appsettings.json b/CloudTheWolf.DSharpPlus.Scaffolding.Worker/appsettings.json.example similarity index 59% rename from CloudTheWolf.DSharpPlus.Scaffolding.Worker/appsettings.json rename to CloudTheWolf.DSharpPlus.Scaffolding.Worker/appsettings.json.example index 0aaf5df..de830fb 100644 --- a/CloudTheWolf.DSharpPlus.Scaffolding.Worker/appsettings.json +++ b/CloudTheWolf.DSharpPlus.Scaffolding.Worker/appsettings.json.example @@ -19,19 +19,5 @@ "user": "mySqlUser", "pass": "MySqlPass", "name": "MyDatabaseName" - }, - "twitch": { - "autostart": true, - "ClientId": "MyTwitchClient", - "AccessToken": "MyTwitchToken", - "AutoAssign": true, - "AutoPurge": true, - "LogChannel": "ChannelIdForLogging" - }, - "Level": { - "MsgExp": 0.012, - "VoiceExp": 0.012, - "PurgeExpOnBan": false, - "RevokeOnMsgDelete": true } } diff --git a/CloudTheWolf.DSharpPlus.Scaffolding.Worker/config.json.example b/CloudTheWolf.DSharpPlus.Scaffolding.Worker/config.json.example deleted file mode 100644 index ad074aa..0000000 --- a/CloudTheWolf.DSharpPlus.Scaffolding.Worker/config.json.example +++ /dev/null @@ -1,28 +0,0 @@ -{ - "token": "{{DISCORD_TOKEN}}", - "prefix": "!", - "enableDms": true, - "enableMentionPrefix": false, - "dmHelp": false, - "enableDefaultHelp": true, - "sql": { - "host": "localhost", - "user": "mySqlUser", - "pass": "MySqlPass", - "name": "MyDatabaseName" - }, - "twitch": { - "autostart": true, - "ClientId": "MyTwitchClient", - "AccessToken": "MyTwitchToken", - "AutoAssign": true, - "AutoPurge": true, - "LogChannel": "ChannelIdForLogging" - }, - "Level": { - "MsgExp": 0.012, - "VoiceExp": 0.012, - "PurgeExpOnBan": false, - "RevokeOnMsgDelete": true - } -} \ No newline at end of file diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..8794ffe Binary files /dev/null and b/logo.png differ