From e20396e0b35bdf41ea0f514331438a0c8c04462f Mon Sep 17 00:00:00 2001 From: moonstar-x <christian.lopez99@outlook.com> Date: Thu, 3 Feb 2022 11:13:35 -0500 Subject: [PATCH] Added an empty message check and error handling to TTSChannel.handleMessage. --- src/classes/tts/TTSChannelHandler.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/classes/tts/TTSChannelHandler.js b/src/classes/tts/TTSChannelHandler.js index 973e0c2d..6590e1f9 100644 --- a/src/classes/tts/TTSChannelHandler.js +++ b/src/classes/tts/TTSChannelHandler.js @@ -14,16 +14,21 @@ class TTSChannelHandler { } async handleMessage(message) { - if (message.author.bot || !message.guild) { - return; - } + try { + if (message.author.bot || !message.guild || message.content?.length < 1) { + return; + } - const channelSettings = await this.client.ttsSettings.get(message.channel); - if (!channelSettings || !channelSettings.provider) { - return; - } + const channelSettings = await this.client.ttsSettings.get(message.channel); + if (!channelSettings || !channelSettings.provider) { + return; + } - return this.handleSay(message, channelSettings); + return this.handleSay(message, channelSettings); + } catch (error) { + logger.error(`Something happened when handling the TTS channel ${message.channel.name} with message from ${message.member.displayName}`); + logger.error(error); + } } async handleSay(message, channelSettings) {