mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
fix: get guild from REST for pk;proxy across clusters
also closes #330.
This commit is contained in:
parent
494f93d629
commit
973d6d883c
1 changed files with 7 additions and 12 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue