Skip to content

Commit

Permalink
Added an empty message check and error handling to TTSChannel.handleM…
Browse files Browse the repository at this point in the history
…essage.
  • Loading branch information
moonstar-x committed Feb 3, 2022
1 parent e284c22 commit e20396e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/classes/tts/TTSChannelHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e20396e

Please sign in to comment.