feat: add 'pk;s <id> avatar' command

This commit is contained in:
spiral 2021-10-30 19:02:21 -04:00
parent 7c9a375393
commit 3e2441cf3a
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31
2 changed files with 16 additions and 5 deletions

View File

@ -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<SystemEdit>(SystemAvatar, m => m.Avatar(ctx, target));
else if (ctx.Match("list", "l", "members"))
await ctx.Execute<SystemList>(SystemList, m => m.MemberList(ctx, target));
else if (ctx.Match("find", "search", "query", "fd", "s"))

View File

@ -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)