diff --git a/src/NadekoBot/Modules/NSFW/NSFW.cs b/src/NadekoBot/Modules/NSFW/NSFW.cs index 1858606c..5e3591db 100644 --- a/src/NadekoBot/Modules/NSFW/NSFW.cs +++ b/src/NadekoBot/Modules/NSFW/NSFW.cs @@ -206,6 +206,15 @@ namespace NadekoBot.Modules.NSFW } } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [OwnerOnly] + public Task NsfwClearCache() + { + _service.ClearCache(); + return Context.Channel.SendConfirmAsync("👌"); + } + public async Task InternalDapiCommand(string tag, DapiSearchType type, bool forceExplicit) { ImageCacherObject imgObj; diff --git a/src/NadekoBot/Modules/Searches/Common/SearchImageCacher.cs b/src/NadekoBot/Modules/Searches/Common/SearchImageCacher.cs index 6ccd9522..323a5eae 100644 --- a/src/NadekoBot/Modules/Searches/Common/SearchImageCacher.cs +++ b/src/NadekoBot/Modules/Searches/Common/SearchImageCacher.cs @@ -165,6 +165,11 @@ namespace NadekoBot.Modules.Searches.Common } return list.ToArray(); } + + public void Clear() + { + _cache.Clear(); + } } public class ImageCacherObject : IComparable diff --git a/src/NadekoBot/Modules/Searches/Services/SearchesService.cs b/src/NadekoBot/Modules/Searches/Services/SearchesService.cs index e4a3e40b..ed87452a 100644 --- a/src/NadekoBot/Modules/Searches/Services/SearchesService.cs +++ b/src/NadekoBot/Modules/Searches/Services/SearchesService.cs @@ -187,6 +187,14 @@ namespace NadekoBot.Modules.Searches.Services } return added; } + + public void ClearCache() + { + foreach (var c in _imageCacher) + { + c.Value?.Clear(); + } + } } public struct UserChannelPair diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index dceae623..ded835c9 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -3771,4 +3771,13 @@ Shows club rankings on the specified page. + + nsfwcc + + + `{0}nsfwcc` + + + Clears nsfw cache. +