From 5599f0a4a811b55de6dc98bb9ba739723106f882 Mon Sep 17 00:00:00 2001 From: Ske Date: Mon, 15 Jul 2019 23:50:32 +0200 Subject: [PATCH] Add system avatar command (which I totally forgot) --- PluralKit.Bot/Commands/SystemCommands.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/PluralKit.Bot/Commands/SystemCommands.cs b/PluralKit.Bot/Commands/SystemCommands.cs index 78f043b6..543d9dbb 100644 --- a/PluralKit.Bot/Commands/SystemCommands.cs +++ b/PluralKit.Bot/Commands/SystemCommands.cs @@ -4,6 +4,7 @@ using System.Runtime.Serialization; using System.Text.RegularExpressions; using System.Threading.Tasks; using Dapper; +using Discord; using Discord.Commands; using NodaTime; using NodaTime.Extensions; @@ -97,6 +98,22 @@ namespace PluralKit.Bot.Commands await Systems.Save(Context.SenderSystem); await Context.Channel.SendMessageAsync($"{Emojis.Success} System tag {(newTag != null ? "changed" : "cleared")}."); } + + [Command("avatar")] + [Alias("profile", "picture", "icon", "image", "pic", "pfp")] + [Remarks("system avatar ")] + [MustHaveSystem] + public async Task SystemAvatar([Remainder] string avatarUrl = null) + { + string url = avatarUrl ?? Context.Message.Attachments.FirstOrDefault()?.ProxyUrl; + if (url != null) await Context.BusyIndicator(() => Utils.VerifyAvatarOrThrow(url)); + + Context.SenderSystem.AvatarUrl = url; + await Systems.Save(Context.SenderSystem); + + var embed = url != null ? new EmbedBuilder().WithImageUrl(url).Build() : null; + await Context.Channel.SendMessageAsync($"{Emojis.Success} System avatar {(url == null ? "cleared" : "changed")}.", embed: embed); + } [Command("delete")] [Alias("remove", "destroy", "erase", "yeet")]