Add system avatar preview as well
This commit is contained in:
parent
468241c92f
commit
c80965394d
@ -14,7 +14,7 @@ namespace PluralKit.Bot.Commands
|
|||||||
public static Command SystemRename = new Command("system name", "system rename [name]", "Renames your system");
|
public static Command SystemRename = new Command("system name", "system rename [name]", "Renames your system");
|
||||||
public static Command SystemDesc = new Command("system description", "system description [description]", "Changes your system's description");
|
public static Command SystemDesc = new Command("system description", "system description [description]", "Changes your system's description");
|
||||||
public static Command SystemTag = new Command("system tag", "system tag [tag]", "Changes your system's tag");
|
public static Command SystemTag = new Command("system tag", "system tag [tag]", "Changes your system's tag");
|
||||||
public static Command SystemAvatar = new Command("system avatar", "system avatar [url|@mention]", "Changes your system's avatar");
|
public static Command SystemAvatar = new Command("system avatar", "system avatar [url|@mention|clear]", "Changes your system's avatar");
|
||||||
public static Command SystemDelete = new Command("system delete", "system delete", "Deletes your system");
|
public static Command SystemDelete = new Command("system delete", "system delete", "Deletes your system");
|
||||||
public static Command SystemTimezone = new Command("system timezone", "system timezone [timezone]", "Changes your system's time zone");
|
public static Command SystemTimezone = new Command("system timezone", "system timezone [timezone]", "Changes your system's time zone");
|
||||||
public static Command SystemProxy = new Command("system proxy", "system proxy [on|off]", "Enables or disables message proxying in a specific server");
|
public static Command SystemProxy = new Command("system proxy", "system proxy [on|off]", "Enables or disables message proxying in a specific server");
|
||||||
@ -31,7 +31,7 @@ namespace PluralKit.Bot.Commands
|
|||||||
public static Command MemberBirthday = new Command("member birthday", "member <member> birthday [birthday]", "Changes a member's birthday");
|
public static Command MemberBirthday = new Command("member birthday", "member <member> birthday [birthday]", "Changes a member's birthday");
|
||||||
public static Command MemberProxy = new Command("member proxy", "member <member> proxy [add|remove] [example proxy]", "Changes, adds, or removes a member's proxy tags");
|
public static Command MemberProxy = new Command("member proxy", "member <member> proxy [add|remove] [example proxy]", "Changes, adds, or removes a member's proxy tags");
|
||||||
public static Command MemberDelete = new Command("member delete", "member <member> delete", "Deletes a member");
|
public static Command MemberDelete = new Command("member delete", "member <member> delete", "Deletes a member");
|
||||||
public static Command MemberAvatar = new Command("member avatar", "member <member> avatar <url|@mention|clear>", "Changes a member's avatar");
|
public static Command MemberAvatar = new Command("member avatar", "member <member> avatar [url|@mention|clear]", "Changes a member's avatar");
|
||||||
public static Command MemberDisplayName = new Command("member displayname", "member <member> displayname [display name]", "Changes a member's display name");
|
public static Command MemberDisplayName = new Command("member displayname", "member <member> displayname [display name]", "Changes a member's display name");
|
||||||
public static Command MemberServerName = new Command("member servername", "member <member> servername [server name]", "Changes a member's display name in the current server");
|
public static Command MemberServerName = new Command("member servername", "member <member> servername [server name]", "Changes a member's display name in the current server");
|
||||||
public static Command MemberKeepProxy = new Command("member keepproxy", "member <member> keepproxy [on|off]", "Sets whether to include a member's proxy tags when proxying");
|
public static Command MemberKeepProxy = new Command("member keepproxy", "member <member> keepproxy [on|off]", "Sets whether to include a member's proxy tags when proxying");
|
||||||
|
@ -289,7 +289,7 @@ namespace PluralKit.Bot.Commands
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (target.System == ctx.System?.Id)
|
if (target.System == ctx.System?.Id)
|
||||||
throw new PKSyntaxError($"This member does not have an avatar set. Set one by attaching an image to this command, or by passing an image URL.");
|
throw new PKSyntaxError($"This member does not have an avatar set. Set one by attaching an image to this command, or by passing an image URL or @mention.");
|
||||||
throw new PKError($"This member does not have an avatar set.");
|
throw new PKError($"This member does not have an avatar set.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,22 @@ namespace PluralKit.Bot.Commands
|
|||||||
public async Task SystemAvatar(Context ctx)
|
public async Task SystemAvatar(Context ctx)
|
||||||
{
|
{
|
||||||
ctx.CheckSystem();
|
ctx.CheckSystem();
|
||||||
|
|
||||||
|
if (ctx.RemainderOrNull() == null && ctx.Message.Attachments.Count == 0)
|
||||||
|
{
|
||||||
|
if ((ctx.System.AvatarUrl?.Trim() ?? "").Length > 0)
|
||||||
|
{
|
||||||
|
var eb = new EmbedBuilder()
|
||||||
|
.WithTitle($"System avatar")
|
||||||
|
.WithImageUrl(ctx.System.AvatarUrl)
|
||||||
|
.WithDescription($"To clear, use `pk;system avatar clear`.");
|
||||||
|
await ctx.Reply(embed: eb.Build());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw new PKSyntaxError($"This system does not have an avatar set. Set one by attaching an image to this command, or by passing an image URL or @mention.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var member = await ctx.MatchUser();
|
var member = await ctx.MatchUser();
|
||||||
if (member != null)
|
if (member != null)
|
||||||
@ -96,16 +112,23 @@ namespace PluralKit.Bot.Commands
|
|||||||
await ctx.Reply(
|
await ctx.Reply(
|
||||||
$"{Emojis.Success} System avatar changed to {member.Username}'s avatar! {Emojis.Warn} Please note that if {member.Username} changes their avatar, the system's avatar will need to be re-set.", embed: embed);
|
$"{Emojis.Success} System avatar changed to {member.Username}'s avatar! {Emojis.Warn} Please note that if {member.Username} changes their avatar, the system's avatar will need to be re-set.", embed: embed);
|
||||||
}
|
}
|
||||||
|
else if (ctx.Match("clear"))
|
||||||
|
{
|
||||||
|
ctx.System.AvatarUrl = null;
|
||||||
|
await _data.SaveSystem(ctx.System);
|
||||||
|
await ctx.Reply($"{Emojis.Success} System avatar cleared.");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// They can't both be null - otherwise we would've hit the conditional at the very top
|
||||||
string url = ctx.RemainderOrNull() ?? ctx.Message.Attachments.FirstOrDefault()?.ProxyUrl;
|
string url = ctx.RemainderOrNull() ?? ctx.Message.Attachments.FirstOrDefault()?.ProxyUrl;
|
||||||
if (url != null) await ctx.BusyIndicator(() => Utils.VerifyAvatarOrThrow(url));
|
await ctx.BusyIndicator(() => Utils.VerifyAvatarOrThrow(url));
|
||||||
|
|
||||||
ctx.System.AvatarUrl = url;
|
ctx.System.AvatarUrl = url;
|
||||||
await _data.SaveSystem(ctx.System);
|
await _data.SaveSystem(ctx.System);
|
||||||
|
|
||||||
var embed = url != null ? new EmbedBuilder().WithImageUrl(url).Build() : null;
|
var embed = url != null ? new EmbedBuilder().WithImageUrl(url).Build() : null;
|
||||||
await ctx.Reply($"{Emojis.Success} System avatar {(url == null ? "cleared" : "changed")}.", embed: embed);
|
await ctx.Reply($"{Emojis.Success} System avatar changed.", embed: embed);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _proxyCache.InvalidateResultsForSystem(ctx.System);
|
await _proxyCache.InvalidateResultsForSystem(ctx.System);
|
||||||
|
Loading…
Reference in New Issue
Block a user