diff --git a/ChaosBot/ChaosBot.csproj b/ChaosBot/ChaosBot.csproj index 7d74f09..93568dc 100644 --- a/ChaosBot/ChaosBot.csproj +++ b/ChaosBot/ChaosBot.csproj @@ -8,6 +8,7 @@ + @@ -18,6 +19,9 @@ PreserveNewest + + PreserveNewest + diff --git a/ChaosBot/ChaosBotSQL.db b/ChaosBot/ChaosBotSQL.db new file mode 100644 index 0000000..314a8dd Binary files /dev/null and b/ChaosBot/ChaosBotSQL.db differ diff --git a/ChaosBot/Controllers/Database.cs b/ChaosBot/Controllers/Database.cs new file mode 100644 index 0000000..353de3d --- /dev/null +++ b/ChaosBot/Controllers/Database.cs @@ -0,0 +1,47 @@ +using System; +using System.Data; +using Microsoft.Data.Sqlite; +using Microsoft.Extensions.Configuration; +using NLog; + +namespace ChaosBot.Controllers +{ + public class Database + { + private SqliteConnection _conn = new SqliteConnection($"Data Source={System.IO.Directory.GetCurrentDirectory()}{Program.Cfg.GetValue("Bot:Database")}"); + private static Logger _logger = Program._logger; + + public DataTable RawQuery(string query) + { + DataTable dt = new DataTable(); + + try + { + using (_conn) + { + _conn.Open(); + + SqliteCommand cmd = _conn.CreateCommand(); + cmd.CommandText = query; + SqliteDataReader executeReader = cmd.ExecuteReader(CommandBehavior.SingleResult); + + dt.Load(executeReader); + + _conn.Close(); + } + } + catch (Exception ex) + { + _logger.Fatal($"Controllers.Database.RawQuery: Exception [{ex}] thrown, <[{ex.Message}]>."); + } + + return dt; + } + } + + public class Raffle + { + private int _id; + private ulong userId; + } +} \ No newline at end of file diff --git a/ChaosBot/Discord/Modules/InfoCommands.cs b/ChaosBot/Discord/Modules/InfoCommands.cs index 1eb1d80..acf25ba 100644 --- a/ChaosBot/Discord/Modules/InfoCommands.cs +++ b/ChaosBot/Discord/Modules/InfoCommands.cs @@ -4,6 +4,7 @@ using System.Text; using Discord.Commands; using System.Threading.Tasks; using System.Collections.Generic; +using ChaosBot.Controllers; using Microsoft.Extensions.Configuration; using NLog; @@ -30,7 +31,7 @@ namespace ChaosBot.Discord.Modules sb.AppendLine(); sb.AppendLine($"Bot Version: {Program.Cfg.GetValue("Bot:Version")}"); sb.AppendLine($"Bot Prefix: {Program.Cfg.GetValue("Discord:Prefix")}"); - + /* * Add the string to the Embed */ diff --git a/ChaosBot/Discord/Modules/RaffleSystem.cs b/ChaosBot/Discord/Modules/RaffleSystem.cs index fe35484..fc3e618 100644 --- a/ChaosBot/Discord/Modules/RaffleSystem.cs +++ b/ChaosBot/Discord/Modules/RaffleSystem.cs @@ -172,8 +172,8 @@ namespace ChaosBot.Discord.Modules private void ClearRaffle(StringBuilder sb, bool noOutput = false) { - _currentPot = new Dictionary(); - + _currentPot.Clear(); + if (noOutput) return; sb.AppendLine($"{Context.User.Mention} has cleared all rafflepoints"); diff --git a/ChaosBot/appsettings.json b/ChaosBot/appsettings.json index 614b027..27ccf36 100644 --- a/ChaosBot/appsettings.json +++ b/ChaosBot/appsettings.json @@ -1,7 +1,8 @@ { "Bot": { "Name": "ChaosBot", - "Version": "1.0" + "Version": "1.0", + "Database": "ChaosBotSQL.db" }, "Discord": { "Token": "NzE3ODM3Njg5Mzk0ODIzMjYy.XtgIew.JWUjvMDSzQT_a36D98CTrtb5lfI",