fix: get guild from REST for pk;proxy across clusters

also closes #330.
This commit is contained in:
spiral 2022-03-30 05:54:21 -04:00
parent 494f93d629
commit 973d6d883c
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -166,18 +166,13 @@ public static class ContextEntityArgumentsExt
public static async Task<Guild> MatchGuild(this Context ctx) public static async Task<Guild> MatchGuild(this Context ctx)
{ {
try if (!ulong.TryParse(ctx.PeekArgument(), out var id))
{
var id = ulong.Parse(ctx.PeekArgument());
var guild = await ctx.Cache.TryGetGuild(id);
if (guild != null)
ctx.PopArgument();
return guild;
}
catch (FormatException)
{
return null; return null;
}
var guild = await ctx.Rest.GetGuildOrNull(id);
if (guild != null)
ctx.PopArgument();
return guild;
} }
} }