Fixed crash when target is missing from message.

This commit is contained in:
ThePendulum 2024-08-15 22:32:00 +02:00
parent 7531a69904
commit 84b158cf21
2 changed files with 6 additions and 1 deletions

View File

@ -35,7 +35,7 @@ function start(length, context, attempt = 0) {
if (answers.some((answer) => answer.word === anagram)) { if (answers.some((answer) => answer.word === anagram)) {
if (attempt >= 10) { 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; return;
} }

View File

@ -117,6 +117,11 @@ async function getGames(bot, identifier) {
const sendMessage = (body, roomId, options, recipient) => { const sendMessage = (body, roomId, options, recipient) => {
const curatedBody = curateMessageBody(body, game, key, options); 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') { if (config.platform === 'irc') {
bot.client.say(/^#/.test(roomId) ? roomId : recipient, curatedBody); bot.client.say(/^#/.test(roomId) ? roomId : recipient, curatedBody);
} }