diff --git a/PluralKit.Bot/Utils.cs b/PluralKit.Bot/Utils.cs index 79823af1..e1229886 100644 --- a/PluralKit.Bot/Utils.cs +++ b/PluralKit.Bot/Utils.cs @@ -75,19 +75,19 @@ namespace PluralKit.Bot { public override async Task ReadAsync(ICommandContext context, string input, IServiceProvider services) { - var conn = services.GetService(typeof(IDbConnection)) as IDbConnection; + var members = services.GetRequiredService(); // If the sender of the command is in a system themselves, // then try searching by the member's name if (context is PKCommandContext ctx && ctx.SenderSystem != null) { - var foundByName = await conn.QuerySingleOrDefaultAsync("select * from members where system = @System and lower(name) = lower(@Name)", new { System = ctx.SenderSystem.Id, Name = input }); + var foundByName = await members.GetByName(ctx.SenderSystem, input); if (foundByName != null) return TypeReaderResult.FromSuccess(foundByName); } // Otherwise, if sender isn't in a system, or no member found by that name, // do a standard by-hid search. - var foundByHid = await conn.QuerySingleOrDefaultAsync("select * from members where hid = @Hid", new { Hid = input }); + var foundByHid = await members.GetByHid(input); if (foundByHid != null) return TypeReaderResult.FromSuccess(foundByHid); return TypeReaderResult.FromError(CommandError.ObjectNotFound, "Member not found."); }