From 5882bbda4e537296c1952dd79a87abe7cdc45a51 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Thu, 30 Jul 2020 01:45:49 +0300 Subject: [PATCH] tags: send bot alert if a tag renders empty and cannot be sent --- backend/src/plugins/Tags/util/onMessageCreate.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/src/plugins/Tags/util/onMessageCreate.ts b/backend/src/plugins/Tags/util/onMessageCreate.ts index 803b6792..62af8030 100644 --- a/backend/src/plugins/Tags/util/onMessageCreate.ts +++ b/backend/src/plugins/Tags/util/onMessageCreate.ts @@ -138,6 +138,13 @@ export async function onMessageCreate(pluginData: PluginData, ms return; } + if (typeof renderedTag === "string" && renderedTag.trim() === "") { + pluginData.state.logs.log(LogType.BOT_ALERT, { + body: `Tag \`${matchedTagName}\` resulted in an empty message, so it couldn't be sent`, + }); + return; + } + const responseMsg = await channel.createMessage(renderedTag); // Save the command-response message pair once the message is in our database