foxwells.vinboard: fixes and cleanup

This commit is contained in:
Cynthia Foxwell 2022-12-02 23:55:08 -07:00
parent 297af07a94
commit 7faa912c00

View file

@ -297,7 +297,6 @@ async function processReaction(_msg, user, reaction) {
).length; ).length;
const dbEntry = await getBoardEntry(msg.id); const dbEntry = await getBoardEntry(msg.id);
logger.debug("vinboard", JSON.stringify(dbEntry));
if (dbEntry) { if (dbEntry) {
if (trueCount == 0) { if (trueCount == 0) {
logger.verbose("vinboard", `Deleting entry for "${msg.id}"`); logger.verbose("vinboard", `Deleting entry for "${msg.id}"`);
@ -308,11 +307,10 @@ async function processReaction(_msg, user, reaction) {
); );
await deleteBoardEntry(msg.id); await deleteBoardEntry(msg.id);
} }
} else { } else if (dbEntry.board_id) {
if (dbEntry.board_id) { const _boardMessage =
const _boardMessage = await board_channel board_channel.messages.get(dbEntry.board_id) ??
.getMessage(dbEntry.board_id) (await board_channel.getMessage(dbEntry.board_id).catch(() => {}));
.catch(() => {});
if (_boardMessage) { if (_boardMessage) {
logger.verbose( logger.verbose(
"vinboard", "vinboard",
@ -324,7 +322,7 @@ async function processReaction(_msg, user, reaction) {
_boardMessage.id, _boardMessage.id,
await createBoardMessage(msg, trueCount) await createBoardMessage(msg, trueCount)
); );
await setBoardEntry(msg.id, trueCount, dbEntry.board_id); await setBoardEntry(msg.id, trueCount, _boardMessage.id);
} else { } else {
logger.verbose("vinboard", `Creating entry for "${msg.id}"`); logger.verbose("vinboard", `Creating entry for "${msg.id}"`);
const boardMessage = await vinboard_webhook.execute( const boardMessage = await vinboard_webhook.execute(
@ -333,7 +331,6 @@ async function processReaction(_msg, user, reaction) {
await setBoardEntry(msg.id, trueCount, boardMessage.id); await setBoardEntry(msg.id, trueCount, boardMessage.id);
} }
} }
}
} else { } else {
logger.verbose("vinboard", `Creating entry for "${msg.id}"`); logger.verbose("vinboard", `Creating entry for "${msg.id}"`);
const boardMessage = await vinboard_webhook.execute( const boardMessage = await vinboard_webhook.execute(