refactor: add SqlKata for SQL generation, move connection handling into ModelRepository

This commit is contained in:
spiral 2021-09-29 21:51:38 -04:00
parent 6251d29abb
commit 92e45a07ff
No known key found for this signature in database
GPG key ID: A6059F0CA0E1BD31
60 changed files with 806 additions and 640 deletions

View file

@ -237,9 +237,7 @@ namespace PluralKit.Bot
if (messageId == null || channelId == null)
throw new PKError(failedToGetMessage);
await using var conn = await _db.Obtain();
var proxiedMsg = await _repo.GetMessage(conn, messageId.Value);
var proxiedMsg = await _db.Execute(conn => _repo.GetMessage(conn, messageId.Value));
if (proxiedMsg != null)
{
await ctx.Reply($"{Emojis.Success} This message was proxied successfully.");
@ -276,8 +274,8 @@ namespace PluralKit.Bot
throw new PKError("Unable to get the channel associated with this message.");
// using channel.GuildId here since _rest.GetMessage() doesn't return the GuildId
var context = await _repo.GetMessageContext(conn, msg.Author.Id, channel.GuildId.Value, msg.ChannelId);
var members = (await _repo.GetProxyMembers(conn, msg.Author.Id, channel.GuildId.Value)).ToList();
var context = await _repo.GetMessageContext(msg.Author.Id, channel.GuildId.Value, msg.ChannelId);
var members = (await _repo.GetProxyMembers(msg.Author.Id, channel.GuildId.Value)).ToList();
// Run everything through the checks, catch the ProxyCheckFailedException, and reply with the error message.
try