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
2 changed files with 16 additions and 5 deletions

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)