diff --git a/PluralKit.Bot/Commands/MemberCommands.cs b/PluralKit.Bot/Commands/MemberCommands.cs index 637bd093..c00a3607 100644 --- a/PluralKit.Bot/Commands/MemberCommands.cs +++ b/PluralKit.Bot/Commands/MemberCommands.cs @@ -186,6 +186,20 @@ namespace PluralKit.Bot.Commands await Context.Channel.SendMessageAsync($"{Emojis.Success} Member deleted."); } + [Command("avatar")] + [Alias("profile", "picture", "icon", "image", "pic", "pfp")] + [Remarks("member avatar ")] + [MustPassOwnMember] + public async Task MemberAvatarByMention(IUser member) + { + if (member.AvatarId == null) throw Errors.UserHasNoAvatar; + ContextEntity.AvatarUrl = member.GetAvatarUrl(ImageFormat.Png, size: 256); + + var embed = new EmbedBuilder().WithImageUrl(ContextEntity.AvatarUrl).Build(); + await Context.Channel.SendMessageAsync( + $"{Emojis.Success} Member avatar changed to {member.Username}'s avatar! {Emojis.Warn} Please note that if {member.Username} changes their avatar, the webhook's avatar will need to be re-set.", embed: embed); + } + [Command("avatar")] [Alias("profile", "picture", "icon", "image", "pic", "pfp")] [Remarks("member avatar ")] diff --git a/PluralKit.Bot/Errors.cs b/PluralKit.Bot/Errors.cs index f9004e63..3ffad1b8 100644 --- a/PluralKit.Bot/Errors.cs +++ b/PluralKit.Bot/Errors.cs @@ -32,6 +32,7 @@ namespace PluralKit.Bot { public static PKError AvatarFileSizeLimit(long size) => new PKError($"File size too large ({size.Bytes().ToString("#.#")} > {Limits.AvatarFileSizeLimit.Bytes().ToString("#.#")}), try shrinking or compressing the image."); public static PKError AvatarNotAnImage(string mimeType) => new PKError($"The given link does not point to an image{(mimeType != null ? $" ({mimeType.Sanitize()})" : "")}. Make sure you're using a direct link (ending in .jpg, .png, .gif)."); public static PKError AvatarDimensionsTooLarge(int width, int height) => new PKError($"Image too large ({width}x{height} > {Limits.AvatarDimensionLimit}x{Limits.AvatarDimensionLimit}), try resizing the image."); + public static PKError UserHasNoAvatar => new PKError("The given user has no avatar set."); public static PKError InvalidUrl(string url) => new PKError($"The given URL is invalid."); public static PKError AccountAlreadyLinked => new PKError("That account is already linked to your system.");