diff --git a/PluralKit.Bot/Commands/CommandTree.cs b/PluralKit.Bot/Commands/CommandTree.cs index c83fce6d..c1d15a45 100644 --- a/PluralKit.Bot/Commands/CommandTree.cs +++ b/PluralKit.Bot/Commands/CommandTree.cs @@ -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 [url|@mention]", "Changes a member's avatar"); + public static Command MemberAvatar = new Command("member avatar", "member avatar ", "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 293a4543..e1b24cb1 100644 --- a/PluralKit.Bot/Commands/MemberCommands.cs +++ b/PluralKit.Bot/Commands/MemberCommands.cs @@ -275,10 +275,37 @@ namespace PluralKit.Bot.Commands public async Task MemberAvatar(Context ctx, PKMember target) { + if (ctx.RemainderOrNull() == null && ctx.Message.Attachments.Count == 0) + { + if ((target.AvatarUrl?.Trim() ?? "").Length > 0) + { + var eb = new EmbedBuilder() + .WithTitle($"{target.Name.SanitizeMentions()}'s avatar") + .WithImageUrl(target.AvatarUrl); + if (target.System == ctx.System?.Id) + eb.WithDescription($"To clear, use `pk;member {target.Hid} avatar clear`."); + await ctx.Reply(embed: eb.Build()); + } + 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 PKError($"This member does not have an avatar set."); + } + + return; + } + if (ctx.System == null) throw Errors.NoSystemError; if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError; - - if (await ctx.MatchUser() is IUser user) + + if (ctx.Match("clear", "remove")) + { + target.AvatarUrl = null; + await _data.SaveMember(target); + await ctx.Reply($"{Emojis.Success} Member avatar cleared."); + } + else if (await ctx.MatchUser() is IUser user) { if (user.AvatarId == null) throw Errors.UserHasNoAvatar; target.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256); @@ -307,13 +334,8 @@ namespace PluralKit.Bot.Commands await ctx.Reply($"{Emojis.Success} Member avatar changed to attached image. Please note that if you delete the message containing the attachment, the avatar will stop working."); } - else - { - target.AvatarUrl = null; - await _data.SaveMember(target); - await ctx.Reply($"{Emojis.Success} Member avatar cleared."); - } - + // No-arguments no-attachment case covered by conditional at the very top + await _proxyCache.InvalidateResultsForSystem(ctx.System); } diff --git a/docs/1-user-guide.md b/docs/1-user-guide.md index b78c4fb9..956b464d 100644 --- a/docs/1-user-guide.md +++ b/docs/1-user-guide.md @@ -208,9 +208,13 @@ To clear a member color, use the command with no color code argument (eg. `pk;me If you want your member to have an associated avatar to display on the member information card and on proxied messages, you can set the member avatar. To do so, use the `pk;member avatar` command. You can either supply it with an direct URL to an image, or attach an image directly. For example. pk;member John avatar http://placebeard.it/512.jpg - pk;member "Craig Johnson" avatar [with attached image] + pk;member "Craig Johnson" avatar (with an attached image) -To clear your avatar, simply use the command with no attachment or link (eg. `pk;member John avatar`). +To preview the current avatar (if one is set), use the command with no arguments: + + pk;member John avatar + +To clear your avatar, use the subcommand `avatar clear` (eg. `pk;member John avatar clear`). ### Member pronouns If you want to list a member's preferred pronouns, you can use the pronouns field on a member profile. This is a free text field, so you can put whatever you'd like in there (with a 100 character limit), like so: diff --git a/docs/2-command-list.md b/docs/2-command-list.md index a68bbe85..8a2ac6d5 100644 --- a/docs/2-command-list.md +++ b/docs/2-command-list.md @@ -33,7 +33,7 @@ Words in \ are *required parameters*. Words in [square brackets] - `pk;member displayname ` - Changes the display name of a member. - `pk;member servername ` - Changes the display name of a member, only in the current serve. - `pk;member description [description]` - Changes the description of a member. -- `pk;member avatar [avatar url]` - Changes the avatar of a member. +- `pk;member avatar ` - Changes the avatar of a member. - `pk;member proxy [tags]` - Changes the proxy tags of a member. use below add/remove commands for members with multiple tag pairs. - `pk;member proxy add [tags]` - Adds a proxy tag pair to a member. - `pk;member proxy remove [tags]` - Removes a proxy tag from a member.