feat: add 'pk;s <id> avatar' command
This commit is contained in:
parent
7c9a375393
commit
3e2441cf3a
@ -329,6 +329,8 @@ namespace PluralKit.Bot
|
|||||||
await ctx.Reply(
|
await ctx.Reply(
|
||||||
$"{Emojis.Error} {await CreateSystemNotFoundError(ctx)}\n\nPerhaps you meant to use one of the following commands?\n{list}");
|
$"{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"))
|
else if (ctx.Match("list", "l", "members"))
|
||||||
await ctx.Execute<SystemList>(SystemList, m => m.MemberList(ctx, target));
|
await ctx.Execute<SystemList>(SystemList, m => m.MemberList(ctx, target));
|
||||||
else if (ctx.Match("find", "search", "query", "fd", "s"))
|
else if (ctx.Match("find", "search", "query", "fd", "s"))
|
||||||
|
@ -304,9 +304,10 @@ namespace PluralKit.Bot
|
|||||||
await Set();
|
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()
|
async Task ClearIcon()
|
||||||
{
|
{
|
||||||
@ -337,18 +338,26 @@ namespace PluralKit.Bot
|
|||||||
|
|
||||||
async Task ShowIcon()
|
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()
|
var eb = new EmbedBuilder()
|
||||||
.Title("System icon")
|
.Title("System icon")
|
||||||
.Image(new(ctx.System.AvatarUrl.TryGetCleanCdnUrl()))
|
.Image(new(system.AvatarUrl.TryGetCleanCdnUrl()));
|
||||||
.Description("To clear, use `pk;system icon clear`.");
|
if (system.Id == ctx.System?.Id)
|
||||||
|
eb.Description("To clear, use `pk;system icon clear`.");
|
||||||
await ctx.Reply(embed: eb.Build());
|
await ctx.Reply(embed: eb.Build());
|
||||||
}
|
}
|
||||||
else
|
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.");
|
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"))
|
if (await ctx.MatchClear("your system's icon"))
|
||||||
await ClearIcon();
|
await ClearIcon();
|
||||||
else if (await ctx.MatchImage() is { } img)
|
else if (await ctx.MatchImage() is { } img)
|
||||||
|
Loading…
Reference in New Issue
Block a user