diff --git a/cogs/wordfilter/wordfilter.py b/cogs/wordfilter/wordfilter.py index 6fb001386a5..60f7a6906dc 100644 --- a/cogs/wordfilter/wordfilter.py +++ b/cogs/wordfilter/wordfilter.py @@ -85,6 +85,12 @@ async def addFilter(self, ctx, word: str): filters = await self.config.guild(ctx.guild).get_attr(KEY_FILTERS)() if word not in filters: + try: + re.compile(word, flags=re.IGNORECASE) + except re.error as e: + await ctx.send(f"`Word Filter:` The word `{word}` is invalid: {e}") + return + filters.append(word) await self.config.guild(ctx.guild).get_attr(KEY_FILTERS).set(filters) await ctx.send(