foxwells.vinboard: fixes and cleanup
This commit is contained in:
parent
297af07a94
commit
7faa912c00
1 changed files with 22 additions and 25 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue