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,11 +307,10 @@ 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(() => {});
 | 
			
		||||
    } 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",
 | 
			
		||||
| 
						 | 
				
			
			@ -324,7 +322,7 @@ async function processReaction(_msg, user, reaction) {
 | 
			
		|||
          _boardMessage.id,
 | 
			
		||||
          await createBoardMessage(msg, trueCount)
 | 
			
		||||
        );
 | 
			
		||||
          await setBoardEntry(msg.id, trueCount, dbEntry.board_id);
 | 
			
		||||
        await setBoardEntry(msg.id, trueCount, _boardMessage.id);
 | 
			
		||||
      } else {
 | 
			
		||||
        logger.verbose("vinboard", `Creating entry for "${msg.id}"`);
 | 
			
		||||
        const boardMessage = await vinboard_webhook.execute(
 | 
			
		||||
| 
						 | 
				
			
			@ -333,7 +331,6 @@ async function processReaction(_msg, user, reaction) {
 | 
			
		|||
        await setBoardEntry(msg.id, trueCount, boardMessage.id);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    logger.verbose("vinboard", `Creating entry for "${msg.id}"`);
 | 
			
		||||
    const boardMessage = await vinboard_webhook.execute(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue