From 3e2441cf3accf11cf49d240747d7b99090b675cd Mon Sep 17 00:00:00 2001 From: spiral Date: Sat, 30 Oct 2021 19:02:21 -0400 Subject: [PATCH] feat: add 'pk;s avatar' command --- PluralKit.Bot/Commands/CommandTree.cs | 2 ++ PluralKit.Bot/Commands/SystemEdit.cs | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/PluralKit.Bot/Commands/CommandTree.cs b/PluralKit.Bot/Commands/CommandTree.cs index de4b41e0..de7a9111 100644 --- a/PluralKit.Bot/Commands/CommandTree.cs +++ b/PluralKit.Bot/Commands/CommandTree.cs @@ -329,6 +329,8 @@ namespace PluralKit.Bot await ctx.Reply( $"{Emojis.Error} {await CreateSystemNotFoundError(ctx)}\n\nPerhaps you meant to use one of the following commands?\n{list}"); } + else if (ctx.Match("avatar", "picture", "icon", "image", "pic", "pfp")) + await ctx.Execute(SystemAvatar, m => m.Avatar(ctx, target)); else if (ctx.Match("list", "l", "members")) await ctx.Execute(SystemList, m => m.MemberList(ctx, target)); else if (ctx.Match("find", "search", "query", "fd", "s")) diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index 7b2ae9ed..29354d46 100644 --- a/PluralKit.Bot/Commands/SystemEdit.cs +++ b/PluralKit.Bot/Commands/SystemEdit.cs @@ -304,9 +304,10 @@ namespace PluralKit.Bot await Set(); } - public async Task Avatar(Context ctx) + public async Task Avatar(Context ctx, PKSystem target = null) { - ctx.CheckSystem(); + if (target == null) + ctx.CheckSystem(); async Task ClearIcon() { @@ -337,18 +338,26 @@ namespace PluralKit.Bot async Task ShowIcon() { - if ((ctx.System.AvatarUrl?.Trim() ?? "").Length > 0) + var system = target ?? ctx.System; + if ((system.AvatarUrl?.Trim() ?? "").Length > 0) { var eb = new EmbedBuilder() .Title("System icon") - .Image(new(ctx.System.AvatarUrl.TryGetCleanCdnUrl())) - .Description("To clear, use `pk;system icon clear`."); + .Image(new(system.AvatarUrl.TryGetCleanCdnUrl())); + if (system.Id == ctx.System?.Id) + eb.Description("To clear, use `pk;system icon clear`."); await ctx.Reply(embed: eb.Build()); } else throw new PKSyntaxError("This system does not have an icon set. Set one by attaching an image to this command, or by passing an image URL or @mention."); } + if (target != null && target?.Id != ctx.System?.Id) + { + await ShowIcon(); + return; + } + if (await ctx.MatchClear("your system's icon")) await ClearIcon(); else if (await ctx.MatchImage() is { } img)