From 973d6d883cdc721dae3bb6ae32fd8d0e7e3bb904 Mon Sep 17 00:00:00 2001 From: spiral Date: Wed, 30 Mar 2022 05:54:21 -0400 Subject: [PATCH] fix: get guild from REST for pk;proxy across clusters also closes #330. --- .../Context/ContextEntityArgumentsExt.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs b/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs index 7c2c7515..521c0fd6 100644 --- a/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs +++ b/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs @@ -166,18 +166,13 @@ public static class ContextEntityArgumentsExt public static async Task MatchGuild(this Context ctx) { - try - { - var id = ulong.Parse(ctx.PeekArgument()); - var guild = await ctx.Cache.TryGetGuild(id); - if (guild != null) - ctx.PopArgument(); - - return guild; - } - catch (FormatException) - { + if (!ulong.TryParse(ctx.PeekArgument(), out var id)) return null; - } + + var guild = await ctx.Rest.GetGuildOrNull(id); + if (guild != null) + ctx.PopArgument(); + + return guild; } } \ No newline at end of file