From 77ed889adcb2ae946c27474019cd5efb31bb715d Mon Sep 17 00:00:00 2001
From: Dragory <2606411+Dragory@users.noreply.github.com>
Date: Sun, 4 Aug 2019 18:08:20 +0300
Subject: [PATCH] Debug

---
 src/plugins/Censor.ts | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/plugins/Censor.ts b/src/plugins/Censor.ts
index f1854f6b..d77deb2c 100644
--- a/src/plugins/Censor.ts
+++ b/src/plugins/Censor.ts
@@ -1,4 +1,4 @@
-import { IPluginOptions } from "knub";
+import { IPluginOptions, logger } from "knub";
 import { Invite, Embed } from "eris";
 import escapeStringRegexp from "escape-string-regexp";
 import { GuildLogs } from "../data/GuildLogs";
@@ -239,8 +239,16 @@ export class CensorPlugin extends ZeppelinPlugin<TConfigSchema> {
 
     // Filter regex
     const blockedRegex: RegExp[] = config.blocked_regex || [];
-    for (const regex of blockedRegex) {
-      // Support supplying your own regex flags with the /<regex>/<flags> syntax
+    for (const [i, regex] of blockedRegex.entries()) {
+      if (typeof regex.test !== "function") {
+        logger.debug(
+          `Regex <${regex}> was not a regex; index ${i} of censor.blocked_regex for guild ${this.guild.name} (${
+            this.guild.id
+          })`,
+        );
+        continue;
+      }
+
       // We're testing both the original content and content + attachments/embeds here so regexes that use ^ and $ still match the regular content properly
       if (regex.test(savedMessage.data.content) || regex.test(messageContent)) {
         this.censorMessage(savedMessage, `blocked regex (\`${regex.source}\`) found`);