diff --git a/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs b/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs index 521c0fd6..6088b8a8 100644 --- a/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs +++ b/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs @@ -80,8 +80,34 @@ public static class ContextEntityArgumentsExt } // Finally (or if by-HID lookup is specified), try member HID parsing: - if (await ctx.Repository.GetMemberByHid(input, restrictToSystem) is PKMember memberByHid) - return memberByHid; + + // For posterity: + // There was a bug that made `SELECT * FROM MEMBERS WHERE HID = $1` hang forever BUT + // `SELECT * FROM MEMBERS WHERE HID = $1 AND SYSTEM = $2` *doesn't* hang! So this is a bandaid for that + + // If we are supposed to restrict it to a system anyway we can just do that + PKMember memberByHid = null; + if (restrictToSystem != null) + { + memberByHid = await ctx.Repository.GetMemberByHid(input, restrictToSystem); + if (memberByHid != null) + return memberByHid; + } + // otherwise we try the querier's system and if that doesn't work we do global + else + { + memberByHid = await ctx.Repository.GetMemberByHid(input, ctx.System?.Id); + if (memberByHid != null) + return memberByHid; + + // ff ctx.System was null then this would be a duplicate of above and we don't want to run it again + if (ctx.System != null) + { + memberByHid = await ctx.Repository.GetMemberByHid(input); + if (memberByHid != null) + return memberByHid; + } + } // We didn't find anything, so we return null. return null;