From 84b158cf21c5cf7d281d9246f083553fb5aa1aa2 Mon Sep 17 00:00:00 2001 From: ThePendulum Date: Thu, 15 Aug 2024 22:32:00 +0200 Subject: [PATCH] Fixed crash when target is missing from message. --- src/games/mash.js | 2 +- src/play.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/games/mash.js b/src/games/mash.js index 9b5022f..b2dbea7 100755 --- a/src/games/mash.js +++ b/src/games/mash.js @@ -35,7 +35,7 @@ function start(length, context, attempt = 0) { if (answers.some((answer) => answer.word === anagram)) { if (attempt >= 10) { - context.sendMessage(`Sorry, I did not find a mashable ${length}-letter word`); + context.sendMessage(`Sorry, I did not find a mashable ${length}-letter word`, context.room.id); return; } diff --git a/src/play.js b/src/play.js index 2dd1252..9fa8ff4 100755 --- a/src/play.js +++ b/src/play.js @@ -117,6 +117,11 @@ async function getGames(bot, identifier) { const sendMessage = (body, roomId, options, recipient) => { const curatedBody = curateMessageBody(body, game, key, options); + if (!roomId && !recipient) { + logger.error(`Missing room ID or recipient for message: ${body}`); + return; + } + if (config.platform === 'irc') { bot.client.say(/^#/.test(roomId) ? roomId : recipient, curatedBody); }