mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-08 06:47:56 +00:00
feat: implement system proxy commands
This commit is contained in:
parent
047bdd870d
commit
cb0a9eaf9f
11 changed files with 93 additions and 29 deletions
|
|
@ -213,6 +213,14 @@ public static class ContextEntityArgumentsExt
|
|||
return channel;
|
||||
}
|
||||
|
||||
public static async Task<Guild> ParseGuild(this Context ctx, string input)
|
||||
{
|
||||
if (!ulong.TryParse(input, out var id))
|
||||
return null;
|
||||
|
||||
return await ctx.Rest.GetGuildOrNull(id);
|
||||
}
|
||||
|
||||
public static async Task<Guild> MatchGuild(this Context ctx)
|
||||
{
|
||||
if (!ulong.TryParse(ctx.PeekArgument(), out var id))
|
||||
|
|
|
|||
|
|
@ -59,4 +59,12 @@ public static class ContextParametersExt
|
|||
param => (param as Parameter.Avatar)?.avatar
|
||||
);
|
||||
}
|
||||
|
||||
public static async Task<Myriad.Types.Guild?> ParamResolveGuild(this Context ctx, string param_name)
|
||||
{
|
||||
return await ctx.Parameters.ResolveParameter(
|
||||
ctx, param_name,
|
||||
param => (param as Parameter.GuildRef)?.guild
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ public abstract record Parameter()
|
|||
{
|
||||
public record MemberRef(PKMember member): Parameter;
|
||||
public record SystemRef(PKSystem system): Parameter;
|
||||
public record GuildRef(Guild guild): Parameter;
|
||||
public record MemberPrivacyTarget(MemberPrivacySubject target): Parameter;
|
||||
public record PrivacyLevel(string level): Parameter;
|
||||
public record Toggle(bool value): Parameter;
|
||||
|
|
@ -83,6 +84,8 @@ public class Parameters
|
|||
return new Parameter.Opaque(opaque.raw);
|
||||
case uniffi.commands.Parameter.Avatar avatar:
|
||||
return new Parameter.Avatar(await ctx.GetUserPfp(avatar.avatar) ?? ctx.ParseImage(avatar.avatar));
|
||||
case uniffi.commands.Parameter.GuildRef guildRef:
|
||||
return new Parameter.GuildRef(await ctx.ParseGuild(guildRef.guild) ?? throw new PKError($"Guild {guildRef.guild} not found"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue