diff --git a/PluralKit.Bot/Commands/CommandTree.cs b/PluralKit.Bot/Commands/CommandTree.cs index c1d15a45..ab303d53 100644 --- a/PluralKit.Bot/Commands/CommandTree.cs +++ b/PluralKit.Bot/Commands/CommandTree.cs @@ -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 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 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 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"); @@ -31,7 +31,7 @@ namespace PluralKit.Bot.Commands public static Command MemberBirthday = new Command("member birthday", "member birthday [birthday]", "Changes a member's birthday"); public static Command MemberProxy = new Command("member proxy", "member proxy [add|remove] [example proxy]", "Changes, adds, or removes a member's proxy tags"); public static Command MemberDelete = new Command("member delete", "member delete", "Deletes a member"); - public static Command MemberAvatar = new Command("member avatar", "member avatar ", "Changes a member's avatar"); + public static Command MemberAvatar = new Command("member avatar", "member avatar [url|@mention|clear]", "Changes a member's avatar"); public static Command MemberDisplayName = new Command("member displayname", "member displayname [display name]", "Changes a member's display name"); public static Command MemberServerName = new Command("member servername", "member servername [server name]", "Changes a member's display name in the current server"); public static Command MemberKeepProxy = new Command("member keepproxy", "member keepproxy [on|off]", "Sets whether to include a member's proxy tags when proxying"); diff --git a/PluralKit.Bot/Commands/MemberCommands.cs b/PluralKit.Bot/Commands/MemberCommands.cs index e1b24cb1..9dbbc993 100644 --- a/PluralKit.Bot/Commands/MemberCommands.cs +++ b/PluralKit.Bot/Commands/MemberCommands.cs @@ -289,7 +289,7 @@ namespace PluralKit.Bot.Commands else { 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."); } diff --git a/PluralKit.Bot/Commands/SystemCommands.cs b/PluralKit.Bot/Commands/SystemCommands.cs index 07b4b511..00760fbc 100644 --- a/PluralKit.Bot/Commands/SystemCommands.cs +++ b/PluralKit.Bot/Commands/SystemCommands.cs @@ -84,6 +84,22 @@ namespace PluralKit.Bot.Commands public async Task SystemAvatar(Context ctx) { 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(); if (member != null) @@ -96,16 +112,23 @@ namespace PluralKit.Bot.Commands 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); } + else if (ctx.Match("clear")) + { + ctx.System.AvatarUrl = null; + await _data.SaveSystem(ctx.System); + await ctx.Reply($"{Emojis.Success} System avatar cleared."); + } 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; - if (url != null) await ctx.BusyIndicator(() => Utils.VerifyAvatarOrThrow(url)); + await ctx.BusyIndicator(() => Utils.VerifyAvatarOrThrow(url)); ctx.System.AvatarUrl = url; await _data.SaveSystem(ctx.System); 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);