From f93291e6044229f12b8e03d21325713fefe45cdc Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Wed, 5 Aug 2020 02:25:32 +0300 Subject: [PATCH] Show BOT_ALERT if tag rendering fails --- .../plugins/Tags/util/renderSafeTagFromMessage.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/src/plugins/Tags/util/renderSafeTagFromMessage.ts b/backend/src/plugins/Tags/util/renderSafeTagFromMessage.ts index 6ac80145..2a662f00 100644 --- a/backend/src/plugins/Tags/util/renderSafeTagFromMessage.ts +++ b/backend/src/plugins/Tags/util/renderSafeTagFromMessage.ts @@ -1,12 +1,14 @@ import { Tag, TagsPluginType } from "../types"; import { Member } from "eris"; import * as t from "io-ts"; -import { StrictMessageContent, stripObjectToScalars, renderRecursively } from "src/utils"; +import { renderRecursively, StrictMessageContent, stripObjectToScalars } from "src/utils"; import { parseArguments } from "knub-command-manager"; import { TemplateParseError } from "src/templateFormatter"; import { PluginData } from "knub"; import { renderTag } from "./renderTag"; import { logger } from "src/logger"; +import { LogsPlugin } from "../../Logs/LogsPlugin"; +import { LogType } from "../../../data/LogType"; export async function renderSafeTagFromMessage( pluginData: PluginData, @@ -36,10 +38,13 @@ export async function renderSafeTagFromMessage( : await renderRecursively(tagBody, renderTagString); } catch (e) { if (e instanceof TemplateParseError) { - logger.warn(`Invalid tag format!\nError: ${e.message}\nFormat: ${tagBody}`); + const logs = pluginData.getPlugin(LogsPlugin); + logs.log(LogType.BOT_ALERT, { + body: `Failed to render tag \`${prefix}${tagName}\`: ${e.message}`, + }); return null; - } else { - throw e; } + + throw e; } }