[Filter] Fix cache invalidation (#2810)

This commit is contained in:
Michael H 2019-06-29 10:30:09 -04:00 committed by Toby Harradine
parent bff7e214ab
commit 8637f8a852

View File

@ -286,6 +286,10 @@ class Filter(commands.Cog):
def invalidate_cache(self, guild: discord.Guild, channel: discord.TextChannel = None):
""" Invalidate a cached pattern"""
self.pattern_cache.pop((guild, channel), None)
if channel is None:
for keyset in list(self.pattern_cache.keys()): # cast needed, no remove
if guild in keyset:
self.pattern_cache.pop(keyset, None)
async def add_to_filter(
self, server_or_channel: Union[discord.Guild, discord.TextChannel], words: list