Merge branch 'master' of ssh://git.chaoticlogic.us:2302/discord-bots/chaosbot
This commit is contained in:
commit
dd08fdd7ae
@ -8,6 +8,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DiceRoller" Version="4.1.0" />
|
<PackageReference Include="DiceRoller" Version="4.1.0" />
|
||||||
<PackageReference Include="Discord.Net" Version="2.2.0" />
|
<PackageReference Include="Discord.Net" Version="2.2.0" />
|
||||||
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="3.0.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
|
||||||
<PackageReference Include="NLog" Version="4.7.2" />
|
<PackageReference Include="NLog" Version="4.7.2" />
|
||||||
@ -18,6 +19,9 @@
|
|||||||
<None Update="appsettings.json">
|
<None Update="appsettings.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="ChaosBotSQL.db">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
BIN
ChaosBot/ChaosBotSQL.db
Normal file
BIN
ChaosBot/ChaosBotSQL.db
Normal file
Binary file not shown.
47
ChaosBot/Controllers/Database.cs
Normal file
47
ChaosBot/Controllers/Database.cs
Normal file
@ -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<string>("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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,6 +4,7 @@ using System.Text;
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using ChaosBot.Controllers;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
|
|||||||
@ -172,7 +172,7 @@ namespace ChaosBot.Discord.Modules
|
|||||||
|
|
||||||
private void ClearRaffle(StringBuilder sb, bool noOutput = false)
|
private void ClearRaffle(StringBuilder sb, bool noOutput = false)
|
||||||
{
|
{
|
||||||
_currentPot = new Dictionary<ulong, int>();
|
_currentPot.Clear();
|
||||||
|
|
||||||
if (noOutput) return;
|
if (noOutput) return;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Bot": {
|
"Bot": {
|
||||||
"Name": "ChaosBot",
|
"Name": "ChaosBot",
|
||||||
"Version": "1.0"
|
"Version": "1.0",
|
||||||
|
"Database": "ChaosBotSQL.db"
|
||||||
},
|
},
|
||||||
"Discord": {
|
"Discord": {
|
||||||
"Token": "NzE3ODM3Njg5Mzk0ODIzMjYy.XtgIew.JWUjvMDSzQT_a36D98CTrtb5lfI",
|
"Token": "NzE3ODM3Njg5Mzk0ODIzMjYy.XtgIew.JWUjvMDSzQT_a36D98CTrtb5lfI",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user