Added .nsfwcc command to prevent memory leaks if nsfw is spammed a lot.
This commit is contained in:
parent
cdf15d6c01
commit
81a7c6f398
@ -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;
|
||||
|
@ -165,6 +165,11 @@ namespace NadekoBot.Modules.Searches.Common
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_cache.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public class ImageCacherObject : IComparable<ImageCacherObject>
|
||||
|
@ -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
|
||||
|
@ -3771,4 +3771,13 @@
|
||||
<data name="clubleaderboard_desc" xml:space="preserve">
|
||||
<value>Shows club rankings on the specified page.</value>
|
||||
</data>
|
||||
<data name="nsfwclearcache_cmd" xml:space="preserve">
|
||||
<value>nsfwcc</value>
|
||||
</data>
|
||||
<data name="nsfwclearcache_usage" xml:space="preserve">
|
||||
<value>`{0}nsfwcc`</value>
|
||||
</data>
|
||||
<data name="nsfwclearcache_desc" xml:space="preserve">
|
||||
<value>Clears nsfw cache.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
Loading…
Reference in New Issue
Block a user