Remove message query reaction AND open DB connection when obtaining one

This commit is contained in:
Ske
2019-07-14 05:23:27 +02:00
parent a41e20a0a3
commit ebc311ecc3
7 changed files with 68 additions and 38 deletions

View File

@@ -34,7 +34,7 @@ namespace PluralKit.Bot
using (var services = BuildServiceProvider())
{
Console.WriteLine("- Connecting to database...");
using (var conn = services.GetRequiredService<DbConnectionFactory>().Obtain())
using (var conn = await services.GetRequiredService<DbConnectionFactory>().Obtain())
await Schema.CreateTables(conn);
Console.WriteLine("- Connecting to Discord...");
@@ -179,7 +179,7 @@ namespace PluralKit.Bot
// and start command execution
// Note system may be null if user has no system, hence `OrDefault`
PKSystem system;
using (var conn = serviceScope.ServiceProvider.GetService<DbConnectionFactory>().Obtain())
using (var conn = await serviceScope.ServiceProvider.GetService<DbConnectionFactory>().Obtain())
system = await conn.QueryFirstOrDefaultAsync<PKSystem>("select systems.* from systems, accounts where accounts.uid = @Id and systems.id = accounts.system", new { Id = arg.Author.Id });
await _commands.ExecuteAsync(new PKCommandContext(_client, arg, system), argPos, serviceScope.ServiceProvider);
}