mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
Remove message query reaction AND open DB connection when obtaining one
This commit is contained in:
parent
a41e20a0a3
commit
ebc311ecc3
7 changed files with 68 additions and 38 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue