diff --git a/src/modules/foxwells.js b/src/modules/foxwells.js index 143a9ff..89b1867 100644 --- a/src/modules/foxwells.js +++ b/src/modules/foxwells.js @@ -297,7 +297,6 @@ async function processReaction(_msg, user, reaction) { ).length; const dbEntry = await getBoardEntry(msg.id); - logger.debug("vinboard", JSON.stringify(dbEntry)); if (dbEntry) { if (trueCount == 0) { logger.verbose("vinboard", `Deleting entry for "${msg.id}"`); @@ -308,30 +307,28 @@ async function processReaction(_msg, user, reaction) { ); await deleteBoardEntry(msg.id); } - } else { - if (dbEntry.board_id) { - const _boardMessage = await board_channel - .getMessage(dbEntry.board_id) - .catch(() => {}); - if (_boardMessage) { - logger.verbose( - "vinboard", - `Updating count for "${msg.id}" (${ - dbEntry.count ?? 0 - } -> ${trueCount})` - ); - await webhook.editMessage( - _boardMessage.id, - await createBoardMessage(msg, trueCount) - ); - await setBoardEntry(msg.id, trueCount, dbEntry.board_id); - } else { - logger.verbose("vinboard", `Creating entry for "${msg.id}"`); - const boardMessage = await vinboard_webhook.execute( - await createBoardMessage(msg, trueCount) - ); - await setBoardEntry(msg.id, trueCount, boardMessage.id); - } + } else if (dbEntry.board_id) { + const _boardMessage = + board_channel.messages.get(dbEntry.board_id) ?? + (await board_channel.getMessage(dbEntry.board_id).catch(() => {})); + if (_boardMessage) { + logger.verbose( + "vinboard", + `Updating count for "${msg.id}" (${ + dbEntry.count ?? 0 + } -> ${trueCount})` + ); + await webhook.editMessage( + _boardMessage.id, + await createBoardMessage(msg, trueCount) + ); + await setBoardEntry(msg.id, trueCount, _boardMessage.id); + } else { + logger.verbose("vinboard", `Creating entry for "${msg.id}"`); + const boardMessage = await vinboard_webhook.execute( + await createBoardMessage(msg, trueCount) + ); + await setBoardEntry(msg.id, trueCount, boardMessage.id); } } } else {