From fb7f31d42d9f9efb0f9f4c25fa6ea5844a61620f Mon Sep 17 00:00:00 2001 From: Ske Date: Mon, 12 Aug 2019 17:49:07 +0200 Subject: [PATCH] Invalidate proxy caches on more editing commands --- PluralKit.Bot/Commands/MemberCommands.cs | 14 +++++++++++++- PluralKit.Bot/Commands/SystemCommands.cs | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/PluralKit.Bot/Commands/MemberCommands.cs b/PluralKit.Bot/Commands/MemberCommands.cs index 2a58b7a3..3209dcd6 100644 --- a/PluralKit.Bot/Commands/MemberCommands.cs +++ b/PluralKit.Bot/Commands/MemberCommands.cs @@ -48,6 +48,8 @@ namespace PluralKit.Bot.Commands // Send confirmation and space hint await Context.Channel.SendMessageAsync($"{Emojis.Success} Member \"{memberName.Sanitize()}\" (`{member.Hid}`) registered! See the user guide for commands for editing this member: https://pluralkit.me/guide#member-management"); if (memberName.Contains(" ")) await Context.Channel.SendMessageAsync($"{Emojis.Note} Note that this member's name contains spaces. You will need to surround it with \"double quotes\" when using commands referring to it, or just use the member's 5-character ID (which is `{member.Hid}`)."); + + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Command("rename")] @@ -80,6 +82,8 @@ namespace PluralKit.Bot.Commands await Context.Channel.SendMessageAsync($"{Emojis.Success} Member renamed."); if (newName.Contains(" ")) await Context.Channel.SendMessageAsync($"{Emojis.Note} Note that this member's name now contains spaces. You will need to surround it with \"double quotes\" when using commands referring to it."); if (ContextEntity.DisplayName != null) await Context.Channel.SendMessageAsync($"{Emojis.Note} Note that this member has a display name set (`{ContextEntity.DisplayName}`), and will be proxied using that name instead."); + + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Command("description")] @@ -173,7 +177,7 @@ namespace PluralKit.Bot.Commands await Members.Save(ContextEntity); await Context.Channel.SendMessageAsync($"{Emojis.Success} Member proxy tags changed to `{ContextEntity.ProxyString.Sanitize()}`. Try proxying now!"); - ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Command("delete")] @@ -186,6 +190,8 @@ namespace PluralKit.Bot.Commands if (!await Context.ConfirmWithReply(ContextEntity.Hid)) throw Errors.MemberDeleteCancelled; await Members.Delete(ContextEntity); await Context.Channel.SendMessageAsync($"{Emojis.Success} Member deleted."); + + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Command("avatar")] @@ -201,6 +207,8 @@ namespace PluralKit.Bot.Commands 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); + + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Command("avatar")] @@ -217,6 +225,8 @@ namespace PluralKit.Bot.Commands var embed = url != null ? new EmbedBuilder().WithImageUrl(url).Build() : null; await Context.Channel.SendMessageAsync($"{Emojis.Success} Member avatar {(url == null ? "cleared" : "changed")}.", embed: embed); + + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Command("displayname")] @@ -250,6 +260,8 @@ namespace PluralKit.Bot.Commands successStr += $"This member will now be proxied using their member name `{ContextEntity.Name}."; } await Context.Channel.SendMessageAsync(successStr); + + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Command] diff --git a/PluralKit.Bot/Commands/SystemCommands.cs b/PluralKit.Bot/Commands/SystemCommands.cs index e77fc485..8d8ee585 100644 --- a/PluralKit.Bot/Commands/SystemCommands.cs +++ b/PluralKit.Bot/Commands/SystemCommands.cs @@ -24,6 +24,8 @@ namespace PluralKit.Bot.Commands public SwitchStore Switches {get; set;} public EmbedService EmbedService {get; set;} + public ProxyCacheService ProxyCache { get; set; } + [Command] [Remarks("system ")] @@ -94,6 +96,8 @@ namespace PluralKit.Bot.Commands await Systems.Save(Context.SenderSystem); await Context.Channel.SendMessageAsync($"{Emojis.Success} System tag {(newTag != null ? "changed" : "cleared")}."); + + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Command("avatar")] @@ -109,6 +113,8 @@ namespace PluralKit.Bot.Commands var embed = new EmbedBuilder().WithImageUrl(Context.SenderSystem.AvatarUrl).Build(); await Context.Channel.SendMessageAsync( $"{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); + + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Command("avatar")] @@ -125,6 +131,8 @@ namespace PluralKit.Bot.Commands var embed = url != null ? new EmbedBuilder().WithImageUrl(url).Build() : null; await Context.Channel.SendMessageAsync($"{Emojis.Success} System avatar {(url == null ? "cleared" : "changed")}.", embed: embed); + + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Command("delete")] @@ -138,6 +146,8 @@ namespace PluralKit.Bot.Commands await Systems.Delete(Context.SenderSystem); await Context.Channel.SendMessageAsync($"{Emojis.Success} System deleted."); + + await ProxyCache.InvalidateResultsForSystem(Context.SenderSystem); } [Group("list")]